Getting together a good development environment for PHP websites isn't that hard any more. On a Windows machine, I recommend a pretty simple approach. Install Xampp, install Eclipse PDT, install XDebug. For bonus points set up Subversion and get TortiseSVN (or, I guess, whatever other version control works for you).
I'll give a quick rundown here on how I set up a development environment on a Windows machine, I tested it as I was writing it and I don't think it took but 2 hours.
Download it from the Apache Friends website . I grabbed the installer (exe) version. Install it to c:\xampp or just adjust all the paths I give you later to match your install path. In the installer I also selected to have Apache and MySQL run as a service but not the FileZilla FTP server (I don't have any need for an FTP server). Xampp has a little control panel that starts and stops the services but in the past I've just used the xampp_start.exe and xampp_stop.exe programs as external tools in Eclipse. (Those might only be useful if you chose not to run Apache & MySQL as a service as I had it set up previously, I'm not sure.)
After Xampp installs you'll default to using PHP5 instead of PHP4. I recommend sticking with 5 - convert your projects now and save a worse headache later. The ini file to tweak PHP will be at c:\xampp\apache\bin\php.ini and the Apache httpd conf file will be at C:\xampp\apache\conf\httpd.conf.
I only use Xampp for local development so I hide it from the outside world by telling Apache to only listen for connections from localhost. I recommend doing this or at least restricting the addresses that can see the development server. Here's how to do what I do.
In httpd.conf, find your Directory section for the root. It will look like
Next you can put Apache on a non-standard port so it isn't so easy to find for a portscanner. I recommend doing this but there are side-effects, like having to use http://localhost:8099/ to see your development site instead of just http://localhost/. Here's how to do what I do.
Look for the Listen directive in C:\xampp\apache\conf\httpd.conf. It will say
After any changes (like these) to httpd.conf you'll need to restart Apache for the changes to take effect. If you're using the Xampp control panel just click the Stop button next to Apache then click the Start button. If you don't run it as a service then I think running xampp_stop.exe followed by xampp_start.exe would do it (do this from a command prompt so you can see any error messages).
The MySQL service can also be exposed to the world at large but I think the default configuration of Xampp keeps it private to your machine and that's the best way to keep it for development.
Get Eclipse PDT
I like Eclipse a lot. It's a great environment for a lot of stuff. I've used it for generic Java development, I used to use PHPEclipse, I've used it for developing on Google Android, I've used it for an XML editor and I even tried a little Python with it. What I've found though is that Eclipse can be slow. I think what made it slow for me was that I had so many plugins running in it. Now I've recently decided that if one Eclipse is good, then two must be better.
Even if you already have Eclipse installed for some other application, I recommend getting the PDT all-in-one download. It's simpler than chasing down the dependencies and I believe it will actually run faster than using one copy of Eclipse with many plugins for different environments.
You can get the PDT all-in-one download by going to the Eclipse PDT downloads page, click on the latest release build then there's a section titled "PDT All-in-One" with a build for each of Windows, Mac or Linux. Currently that link points to this list of mirrors here but you really should start at the Eclipse PDT downloads page to get the latest version.
Once you've downloaded the zip file extract it to the place you want Eclipse to live. When something doesn't have an installer I often put it under c:\util, so mine lives at c:\util\eclipse-pdt. To launch it I made a shortcut to c:\util\eclipse-pdt\eclipse.exe on my quicklaunch toolbar (just dragging the exe file does this in Windows XP but right-click dragging is safer).
Start up Eclipse and it will ask you where you want your workspace. I made my workspace the same as Apache's DocumentRoot for convenience. If you installed the same way as I described above then that means c:\xampp\htdocs. If you don't do this then every time you create a new project that corresponds to some PHP files then you'll need to override the default location for the project. In my case I just override the few projects that don't live in my DocumentRoot. Next Eclipse will start up with a Welcome screen you can safely close. I'm not going to explain everything about how to use Eclipse or PDT but I'll walk you through making one project.
On the left side there's a window titled Project Explorer. This window and others like it are called Views and you can open Views from the Window menu. Right-click in the Project Explorer view and pick New Project off the context menu that appears. In the New Project Wizard pick PHP -> PHP Project and click Next. The next dialog asks for a Project Name. The Project Name, by default, corresponds to the folder name under where your project files will live. Xampp comes with some files under htdocs\xampp, so lets make an Eclipse project where you can poke around at them. Just give the project the name "xampp" and the Directory will (if you've done everything the same as me) will be c:\xampp\htdocs\xampp. Click Finish and the new "xampp" project shows up under the Project Explorer. Eclipse might also ask you if you want to switch to the PHP Perspective at this point (you do). A perspective is basically a collection of Views. The PHP Perspective is the one you want to use for PHP development. You can open perspectives from the Window menu or from a little button near the top of your Eclipse window (you can find it yourself, I'm not taking pictures today). Each open perspective also has a button that shows up near the top of the Eclipse window to allow you to quickly switch from one perspective to another. This is especially useful for switching from the PHP to the PHP Debug perspective and back.
If you've never used a real debugger then you'll have to get to know a couple concepts. Basically the way a lot of debuggers (including XDebug) work is by splitting the work into a debug server and a debug client. XDebug is a debug server. There's a debug client available on the same site but it's basically just useful for testing purposes (I've used it to test on Linux but to test on Windows I used XDebugClient).
When you visit a page with the debug server running, the server will try to connect to a listening debug client. The debug client and server then exchange some information and your debug client can control what's going on and give you information about the state of the program you're debugging. In this case the debug client we want to use is a part of Eclipse PDT.
There are a few places that describe how to set up the XDebug server in PHP, the official docs are a good place to start but there are more details spread around that site and others. All you need to do is make a couple tweaks to c:\xampp\apache\bin\php.ini. Xampp has the lines you need but they're commented out:
So you can see that Xampp tells you where they think XDebug goes. So move php_xdebug-2.0.3-5.2.5.dll to C:\xampp\php\ext\ and change the [XDebug] section to look like this:
Xampp also comes configured for Zend Optimizer which is incompatible with XDebug. You'll get an error like "Zend Optimizer 3.3.0 is incompatible with Xdebug 2.0.3" when Apache starts if you try to use both. You need to find the section like this in PHP.ini
and either delete it or comment it out like so
Any time you change php.ini you need to restart Apache, so do that too.
Now we're ready to test the debugger. In Eclipse, open up C:\xampp\htdocs\xampp\index.php - it's in the project we created earlier. On the Run menu choose "Open Debug Dialog..." and you'll get a Debug dialog that lets you define debug settings. You can have several debug configurations for different projects or scenarios. Right now we just want to make one for demonstrating the debugger (after that you can figure out how to apply it to your own stuff). On the left side of the dialog, double click "PHP Web Page" and you'll get a new debug configuration called "New_configuration". On the Server tab, under Server Debugger, choose XDebug. In the File edit box, fill in "/xampp/index.php" (or use the Browse button to find it). Next, uncheck the Auto Generate box in the URL section. You can only fill in the second part of the URL here because the server name part is decided by servers configured in Eclipse (I'll come back to that in a minute). In the second URL edit box, you'll want to replace "/index.php" with "/xampp/index.php". If you didn't change the port for Apache then you should be all set here.
Oh, you changed the port for Apache like I said you should? Then you need to do one more thing before you make the Debug Configuration. In Eclipse, go to Window->"Preferences..." and on the left side of the Preferences dialog, find PHP, click the + then pick "PHP Servers" under it. You'll see the "Default PHP Web Server" has an address of "http://localhost". All you need to do is change that to match the port for Apache, like "http://localhost:8099". Click Okay a couple times and then go do the Debug Launch Configuration I described just above.
After you've set up your Debug Configuration you can just click the little bug button in the PHP perspective to start it again. If something goes wrong and you get an error message like "Web Launch Already Running!" then you need to stop the debugger before trying again. To do that, go to the PHP Debug perspective. To get to the PHP Debug perspective, look for a button near the top of the Eclipse window that says "PHP Debug". If you don't see it just go to the Window menu, pick "Open Perspective" and pick "PHP Debug" from there. Once you're in the PHP Debug perspective, you'll see a View titled "Debug".