If you want to setup a web development environment in your PC, there are many options out there, so I’m going to describe the one that just worked for me.
This is a no-frills tutorial about how to setup a web development environment for PHP, using
- An EeePC 1000H as the local machine
- A wireless ADSL network for the internet connection
- WinXP/SP3 Home as the operating system
- Apache as the web server
- MySQL as the database management system
- PHP as the source language
- Subversion and Tortoise for source control management
- Eclipse PDT as the integrated development environment
- Zend Debugger for remote debugging
- Zend Framework as the supporting framework
A PC connected to the internet
Apache, MySQL, PHP
This is very easy too. There are many all-in-one packages, but I feel at home with the WampServer.
- Download and install the WampServer 2.0
Subversion and Tortoise
XP-Dev is my choice for Subversion hosting. Easy to setup and free. Nobody else will get access to your code by default, but you can change it as needed. Slick interface, fast updates and commits, (apparently) trustworthy.
- Create your account at XP-Dev. You’ll currently get 1500 MB of svn hosting space.
- Login and create your first repository. Its name will be <your XP-Dev account>_<your repository name>
Tortoise is my choice for the svn administration. Easy to setup and free (again).
- Download and install Tortoise.
Tortoise is for dummies like me. Just righ click in a folder and the contextual menu will show all the needed options.
- Create a local folder for mirroring your remote project repository. Don’t put it under the www folder of Apache.
- Checkout the repository there. This will setup the link between them.
- Into the local folder create the classical trunk, tags, and branches folders.
- Commit all back to the repository, together with a nice comment.
If all goes well, your new source control management system is correctly setup.
It’s important that you unzip into the root, otherwise some files won’t unzip due their long path names. Eventually, you’ll get an eclipse folder, containing an eclipse executable.
- Start eclipse and learn how to move around.
- Create a new PHP project, into the trunk folder.
- Open the trunk folder from WinXP and add to the ignore list of Tortoise all the files automatically created by eclipse. Then commit.
Even if you think that the Zend Debugger was bundled with the all-in-one Eclipse PDT, follow this step too. In fact, that Zend Debugger is not for server debugging, while this one is.
- Download and unzip Zend Debugger.
- Follow the short instructions of the readme file to intall it. For editing the php.ini, use the link provided by WampServer.
You could use any other framework, or no framework at all, but I know the Zend Framework quite a bit.
- Download and unzip the Zend Framework.
The Zend Framework site provides a QuickStart tutorial that sets up an “Hello World” application.
- Activate in Apache (WampServer) the rewrite module.
- Create in Apache (WampServer) an alias from ‘project’ (trim apostrophes) to the trunk folder of your project.
- Go back to the IDE and code in the QuickStart tutorial. Don’t put the ZF library into the trunk/library folder. Instead leave it where it is and put its path into the include_path directive of php.ini, using WampServer.
That’s much better, because your current ZF library version won’t replicate by means of svn to your remote repository, and when a new version will be available, you can change the include_path directive to point to it, and change it back if something goes wrond (sometimes it does), without moving files around.
Moreover, you can use the trunk/library folder for your own library files. I suggest a personal folder for your reusable classes like forms, elements, filters, and validators, and a Zend folder that mirrors the Zend Framework when you need to fix a bug in a class, or hack something into the ZF library.
Due to the fact that the PHP interpreter will scan the trunk/library folder before the external ZF library folder (if you set up the include_path as shown in the QuickStart tutorial), you can “overwrite” the ZF library classes with your copies if you need, on the fly, maintaining them well apart.
First debugging session
Now your web development environment should be setup and you can start your first debugging session.
- Open the home page http://localhost/project/ in a browser.
- Start the debugger at that page, using Eclipse PDT. Check that the URL into the Debug Configuration dialog is correct, and the option ‘Break at first line’ is checked.
- Explore the code step by step.
- If all is OK then commit, else fix bugs.
That’s alll. Now it’s up to you.