but as such freebie, the setup of the dev env, is not that straight forward.
while you can definitely develop PHP without an IDE, just with a text editor, it is agruably time consuming to work on nasty bugs without a debugger...
so this is yet another tutorial of "how to set up PHP debugging on windows with Apache".
Prerequisites:
- Installed apache web server with PHP- there are numerous all-in-one setups "a la" LAMP. to name some xampp, wamp, mamp for mac etc' (google it, you'll find more).
I'll be using xampp for this example, it is also well integrated into the PDT. you can download it at http://www.apachefriends.org/en/xampp.html - Sun's Eclipse PDT - it's a setup built to debug PHP, so it has the proper php-debug prespective we're after. downloadable from here:
http://www.zend.com/community/pdt?ecl=EclipseZend - ZendDebugger dll:
http://downloads.zend.com/pdt/server-debugger/
choose the zip file that regards windows (currently ZendDebugger-5.2.15-cygwin_nt-i386.zip )
make sure you're extracting the 5_2_x_comp/zenddebugger.dll, assuming that you're using php 5.2.x
and put the dll in any location (i usually put it in the eclipse root dir or xampp root dir).
Making the bastard run:
changing the php ini file to support debugging with Zend
* make sure you're changing the right php.ini file by running the phpinfo()- can be done usually through the interface like (http://localhost:82/xampp/phpinfo.php
* you cannot run both xdebug and zend, so comment out all the [xdebug] category lines
* sometimes you'll find that the zend optimizer cannot run together with zend debugger, so comment out those as well, since it is not a production env - u don't need it anyway.
like the following section:
[Zend];
zend_extension_ts = "C:\xampp\php\zendOptimizer\lib\ZendExtensionManager.dll"; zend_extension_manager.optimizer_ts = "C:\xampp\php\zendOptimizer\lib\Optimizer"; zend_optimizer.enable_loader = 0;
zend_optimizer.optimization_level=15;
zend_optimizer.license_path = ...
so just comment it out using semicolons ";" at the begining of the line.
* now you're ready to add the Zend debugging lines:
[ZendDebug]
zend_extension_ts="C:\Program Files\eclipse\ZendDebugger.dll"
zend_debugger.expose_remotely=always
zend_debugger.allow_hosts=127.0.0.1/32
I'm not sure that the /32 of the IP in the allow_hosts config does, but it works that way, just leave it...
5. now we need the dummy.php which is the test file for PDT to see that the debugger works.
I found one saint that posted the contents of the file: http://www.webtdo.com/dummyFile.php
you need to create a file called dummy.php and put it in the document root - eclipse will be looking for it.
6. configuring eclipse.
* open eclipse, any workbench is ok, just create a new php project.
* on window->preferences->php->debug->installed debuggers, edit the client host/IP and leave only the 127.0.0.1
* now open the debug configurations, create a new PHP web page configuration, and select Zend as the server debugger, and configure the PHP server to point to your apache root including the port number if other than 80.
* hit test debugger - if it says success - we're good, otherwise you need to start thinking about what went wrong: is apache up? is dummy.php in place? is zend debug section added to the right php.ini file? etc'.
*select the file to start from, and the "debug" button should start being enabled.\
that's it! we're good as new.
good luck folks, it's not trivial, i know...
No comments:
Post a Comment