Local PHP Development
Many developers have their own techniques for improving the local development experience. I used to do all my development live, but I have found that model too restrictive as of late. Currently, the local development model I use involves XAMPP and InstantRails. XAMPP I use for PHP / Perl development, and InstantRails I use for Ruby / Rails development. My editor of choice has recently become e-texteditor.
XAMPP for Windows
XAMPP, a free, cross-platform stand alone server, is centered around the popular Apache web server. Along with Apache I have access to a MySQL server, and interpreters for PERL and PHP. The installation is very easy, and with a few modifications post installation you can have a great development environment.
After XAMPP Installation
Being able to work on multiple sites at once locally is critical. What is also critical is staying efficient. I made the decision early on in my setup that I didn’t want to have to type localhost/path/to/project for each new project. To take care of this issue I had to modify the /path/to/xampp/apache/conf/extra/httpd-vhosts.conf file, and the C:\WINDOWS\system32\drivers\etc\hosts file. You may also have to modify the /xampp/apache/conf/httpd.conf file if the following line of code is commented out (around line 500ish):
Include conf/extra/httpd-vhosts.conf
To uncomment you may need to remove the pound sign preceding the code.
httpd-vhosts.conf
Here we are setting up virtual hosts to direct a url to a folder housing an app. The url should reflect the application you are building. For example:
NameVirtualHost 127.0.0.1:80<VirtualHost 127.0.0.1:80>DocumentRoot "C:/Path/to/xampp/htdocs/"ServerName localhostServerAdmin admin@localhost</VirtualHost><VirtualHost local.app.com:80>DocumentRoot "C:/path/to/development/folder"ServerName local.app.comServerAdmin admin@local.app.com<Directory "C:/path/to/development/folder">Options Indexes FollowSymLinksAllowOverride FileInfoOrder allow,denyAllow from all</Directory></VirtualHost>
For each new application you want to work with just repeat lines 2 - 17 in the above example and fill in the appropriate data. It’s important to note that the server name for your app (line 09) can be anything you want. It’s a good idea to keep it relevant to the application you are developing. It’s also important to note that for any change you make to your apache configuration you will likely have to restart the server to see those changes take affect.
C:\WINDOWS\system32\drivers\etc\hosts (win XP)
The last thing you need to do is to modify your windows host file. This instructs windows to point URLs typed into the address bar to a specific IP address. In our case, 127.0.0.1, the local IP address.
127.0.0.1 localhost127.0.0.1 local.app.com
If you compare the above two code snippets, you will notice that local.app.com will load our local IP, and our virtual host instructs the server to point this URL to the specified directory. Adjusting the above two files for each new application should result in smoother development.
You can find a lot more information about using XAMPP (Apache-MySQL-PHP-Perl) for Windows online.
During development I also version the applications I am working on with Subversion, however that is a topic for another time.





