Choosing the right PHP development environment

When I first started coding PHP websites, I was using Emacs on a Linux computer. Then I switched to UltraEdit on Windows. I had a Linux server on the local network running Apache with PHP and MySQL. My projects were on the server and I was accessing the files through Samba. When developing locally, I switched my hosts file in order to point my website’s hostname to my local server instead of the production one. I was using FTP to put files online. Today I’m using a much more evolved approach as the following describes…

Team work

Although this works quite fine when you’re alone, it doesn’t anymore when a team of several developers are working together. What happens when two persons edit the same file? This could result in data loss. The solution to this problem is that every developer has his/her own copy of the source code on his/her machine and that we’re using a CVS like Subversion or Git. I’m personally using Subversion so that’s the one I’ll be talking about. Such a system allows developers to collaborate on a project. Source code and its history are stored on a remote server. Versionning conflicts are resolved either automatically or by the user himself. I won’t go into details in here as there are already plenty of information available on the Internet. On Windows, I recommend installing Tortoise svn while on Linux or Mac OS X you’ll easily find a Subversion package. With Eclipse, the easiest way is to you Subversion’s Eclipse plugin: subclipse.

Standalone environment for everyone

As each developer has its own copy of the source code, the simplest thing is for everyone to have his/her own web server.

On Windows, the easiest way is to use an all-in-one distribution like XAMPP. This package provides Apache, PHP, MySQL and many common PHP extensions (provided as already compiled DLLs of course).

Today I’m on Mac OS X Snow Leopard and while XAMPP also exists for Linux or Mac OS I prefer compiling things myself. There’s an excellent tutorial at the following address that will explain you how to install Apache 2 and PHP5 on a Mac using MacPorts:

How do I access my personal web server?

Although you can use subdirectories of your web server (http://localhost/project/), you may find it more convenient to use its real URL by overloading it in your hosts file (by adding an entry like The inconvenient with this method is that you need to change your hosts file and reload your browser every time you need to switch from dev to production. I’m personally using specific hostsnames for my projects such as for example. This can be either a real hostname like while the production one is or a fake hostname like The former needs a real hostname set up to point to while the latter only requires an entry in your hosts file. The idea behing this solution is for every developer to use the same URLs on their machines which can be useful.

And what about the database?

Well… that depends on what you will be doing. Here are the questions that you and your developers need to address:

  • does every developer often modify the structure of your database on tables also used by others?
  • do you need to be working with regularly updated data?
  • is everyone working on the same local network or do you need worldwide database access?

Personally I’m using one database server hosted on the Internet so everyone can access it whether it is from the office or outside of it. This MySQL server gets the data from the production sever every night so we’re always working with accurate data. We actually have two different databases on the same server with the same data updated nightly so that when someone needs to change the structure and that it affects others, he can change the database he’s using. Of course, synchronization can be temporarily deactivated so that our changes are not lost every night.

Code editing

I’ve been using Eclipse for a while now and I really like it. Eclipse PDT has all the tools you need for PHP developments… except subclipse that is not installed by default.

Versionning: using branches or the trunk?

CVS repositories are usually structured as follows: the trunk represents the main line of development, tags are snapshots of your project’s status in time (1.0 stable version or pre-release for example), and finally branches consist of specific subdivisions of your project: for example, when a subteam of developers start working on a big and long modification of your project, they should create a new branch. At least that’s how I’m working.

The production server gets files from the trunk so everyday work is performed on the trunk. When starting lengthy projects that prevents files from being commited before the whole thing is finished, we’re creating a new branch. Keep in mind that you may have to fix critical bugs quickly without waiting for a long project to be finished to put your fix online!

Leave a Reply

Your email address will not be published. Required fields are marked *