Skip to main content

Posts

Clean URLs in PHP Yii Framework

Here is a quick tip to save some trouble. The goal here is to get clean urls like http://localhost/site/test/5 or http://localhost/site/contact without having a query string variable and also not having the filename index.php show up. My configuration: EasyPHP (apache/php/mysql combo for windows) Yii PHP framework In the Yii main.php configuration file you need: 'urlManager'=&gt;array( 'urlFormat'=&gt;'path', 'showScriptName'=&gt;false,), Inside the ‘components’ array area. In the primary directory where the index.php file is you need a .htaccess files with this in it: Options +FollowSymLinks IndexIgnore */* RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^ index.php [L] If you have problems, check your httpd.conf file for these items: <directory c:\easyphp\www> Inside that directory section, make sure the rules don’t disallow the removal of index.php or the other rewrite rule...

Setting Up Netbeans and Ruby

I’ve been considering some development with Ruby and Rails. As I’ve used the Netbeans IDE before and liked it, I downloaded the Ruby version to give it a try. The main benefit here is that you can do a lot of things without the console. I can add models, scaffolds, migrate databases, and such with a few clicks. The current default install doesn’t have the most current version of “JRuby” (that being ruby created with 100% Java) installed, so I opted to figure out how to update Netbeans with the most current interpreter. Here is a quick list of things to do: download the Ruby Netbeans IDE Download latest version of JRuby Install the new version to: C:\Program Files\NetBeans 6.7.1\ruby2\ Depending on your install directory of Netbeans. A directory will be created: jruby-1.4.0 Depending on the currently available version of JRuby. In Netbeans, go to the platform manager in the menu “tools >> Ruby Platforms”: Select auto-detect platforms, or add ...

Grids and ASP.NET (vb)

Manually filling rows of data in ASP.NET controls can be a bit unintuitive. I’ll go over a few things I learned recently. I’m writing up this posting off the top of my head, so I can’t say for certain the code examples are correct in syntax. Use the template field in your grid view as it’s the most flexible to deal with as apposed to using asp bind field tags or other means. <asp:TemplateField HeaderText="A Column"> <ItemTemplate> <a href="http://address"><%# Bind("dbField") %></a> </ItemTemplate> </asp:TemplateField> The example above is a column template field with the Bind() function call. Bind() is a special function that can be used to link data that the template field has access to within the grid row. You can also use Eval() which just prints the data and does not hard link the control and data like Bind() does. Also take note of the # in the asp tags <%# %> this is shorthand for...

Short-circuit conditionals in VB.NET

I’m in a situation now where I am required to write programming code in VB.NET. Which brings me up to a simple programming construct that I came upon by writing code like I would in C#, but getting a different expected result in VB.NET. In C#, using the && operator in conditionals is *by default* a short-circuit type conditional. That means when the first term is evaluated, the additional statements won’t be processed at all if that first statement was not true. The main benefit is something like this: Say, you want to check a listbox for specific values… if(lb1.selectedIndex > -1 && lb1.selectedValue.compare(“value text”) == true) { code to run } If the list box has no list items in there (eg. a selectedIndex of -1), the second condition will never be checked. If C# did not short circuit after the first term resulted in false, a program error would occur because the second condition would not have anything set for the selectedValue property. Oddly enough, in VB...

EasyPHP, Wordpress, and Permalinks

I’m creating a website as a favor to a friend. To save effort, I’m just doing the development on my Windows computer. While doing that, I ran into a little issue with permalinks that seems to be unique to how EasyPHP is configured. While I won’t go into much detail on the subject, I re-affirmed the fact that WordPress is as close to as ideas as one can get when wanting to setup a basic website. I tried out probably 10 open source CMS systems and found them too complex (the admin back-ends) or too buggy to be used. Keep in mind that the website I am setting up requires only basic functionality (informational pages, a image gallery, good admin, stable code), which is what I am basing my opinion off of. What brings me to my post today is that I used EasyPHP  (a simple Apache, MySql installer and admin) to act as the local web server for testing. I was having issues with getting permalinks working. There was one gotcha that doesn’t apply to other webserver installers. What I did t...

Using Linux

I’ve used linux/unix quite a bit over the years. Probably my first experience with Linux was when I bought a magazine in the 90’s that had Mandrake linux on CD. Since then I’ve used distributions from Slackware to Ubuntu, but never really had a desire to do much with the OS once I had it running, so it just usually sat on my harddrive. I have recently been reminded why I was never interested in using *nix exclusively. Don’t get me wrong here, I think the concept of free open-source software operating systems is great. (Edit 09/2010: I’ve been using Ubuntu Linux 10.04 and have had generally a good experience with it for a few months as my primary desktop. I’m going to keep using it…) Let me go over a scenario to explain my thoughts: Goal: Setup Debian Linux so that I can test my software. I specifically want to use a VMWARE appliance so that I don’t have to mess around with my current OS. (Edit: I’ve since switched over to Sun’s VirtualBox software, which is much better than t...

Site Redesign

I was due for a site software update, so I decided to modify the site as a whole. My main goal was simplification and to improve on usability.  As I went through the visual-template code, I also attempted to improve execution speed by minimizing include files and removing unnecessary features. Minimize the website banner to remove wasted space (logo redesign as well). Remove unpopular items from the site such as the forums. Reorder the site tags, recent postings, and other navigation links to improve on ease of use. Lessen the use of colors on the site. Clean up the footer area. I’ve noticed that the site seems to load faster in general. I suspect something like that XML parser for the forum was decreasing overall speed quite a bit.

.NET and MONO

I’ve been working on a personal project with a friend for quite a while now.  To make a long story short it deals with loading/editing/saving large quantities of public geographic data. Lately we have been throwing around the idea of having our database server’s OS in Linux instead of Windows 2000. Which brings me to the MONO project. I’ve started testing some code I wrote in C# (a console application that accesses the Internet) by using that MS Virtual PC program I setup in my previous posting with Xubuntu. While my current goal changed a bit, I’m glad to start getting some use out of it. Basically, all I needed to do was install the mono run-time libraries and I was good to go. Now keep in mind that some Linux distributions might only have older versions of MONO available by way of a package manager (or pre-install). In this case you should see if your .NET application requires something that the available version of MONO does not have by visiting the mon...

Virtualization

I’ve been interested lately in using virtualization to setup a “computer” to do local web development on. I’m looking to configure it it closely as possible to my paid hosting, so that it will be as easy as possible when I take a project and migrate it over to to the host. If you haven’t had any experience with virtualization, it’s basically a way of running an operating system inside whatever operating system you are currently using. The nice thing about it these days is that more recent processors have hardware extension to improve performance to the level where it’s quite usable. The software mimics all aspects of a basic computer with standard hardware. So you take your operating system install disk and go through the process as you normally would. I am currently using Windows Vista Ultimate x64. So looking at the easiest option, I downloaded and installed Microsoft’s free “Virtual PC 2007” program. I’ve used it...

PHP, IIS, and NetBeans

It’s been while since I have used the language, so I thought it would be fun to try making a few new ideas with it. I did a quick search to see what PHP IDEs were available.  I’ve used Eclipse quite a lot, but I’m not particularly fond of it, so I wanted to try something else. I plan on giving NetBeans a chance to see how it fairs. http://www.netbeans.org/features/php/ Seeing as I am currently using Vista Ultimate 64-bit, I decided to just use IIS. I had a few quips getting it working. I had modified IIS beforehand when I was doing some old VbScript coding, so needless to say when I tried installing PHP it didn’t work out of the box. In the IIS configuration program (use the start button search in vista on “InetMgr”): Install PHP as a ISAPI filter. In your selected application pool advances settings, make sure that “Managed Pipeline Mode” is set to “Classic” mode. In the list of global settings: Add a default document “index.php” In ISAPI Filters, add a new filter that points to (...