Thursday 26 January 2012

Install and configure PHP on your machine

This might seem like an easy thing to do but you would not believe the issues I have had while setting up PHP on a 64bit W7 machine.
The intention is to run it under Tomcat as detailed elsewhere, so this is a non standard install which I also want to be able to debug through eclipse.
The steps are as follows:
  1. Down load the correct version of PHP.
    I went with the Thread safe 5.3.9 version.
    I'm not sure if that was the right choice but I followed the advice listed here. My thoughts were that I want apache/tomcat to handle multiple threads so I expected PHP to do the same.
    Note the debug pack seems to be related to creating stack traces when PHP crashes.
  2. During the install it asks where to install, I wanted to keep it out of the program files directory so I placed it in "C:\development\php\php_5.3.9\".
  3. During the install it asks for the web server set up.
    As Tomcat is not present and I have no Apache or ISS I opted for the Other CGI version.
    (I am not sure at this point if that is causing problems later with debugging).
  4. After the install you should be able to open a command prompt and check every thing is working.
    Simply type php -i  and this will dump the PHP info to screen.
    Running a PHP script is now as simple as "php myfile.php". 
  5. For the next step create a dump of this info:
    php -i > phpinfo.txt
  6. As I want to debug PHPs I need more software XDebug to be exact.
    (There is an other debugger called Zend which looks nice but it is a commercial package and I can't get it at this time.)
    So where do you go to get XDebug ... http://xdebug.org/find-binary.php.
    Take the captured output (phpinfo.txt) and post it to the form on the above page.
  7. Now follow its instructions.
    It should tells you which dll to download (plus a link) and where to put it (the /ext folder) and what to place into the php.ini file.
    Mine ended up looking like this:

    [PHP]
    ; XDEBUG
    zend_extension = C:\development\php\php_5.3.9\ext\php_xdebug-2.1.2-5.3-vc9.dll

    And you can check it is a loaded module by typing php -m which will dump the following:

    ...
    tidy

    tokenizer
    wddx
    xdebug
    xml
    xmlreader
    xmlrpc
    xmlwriter
    zip
    zlib
    [Zend Modules]
    Xdebug
  8. To confirm the set up redo steps 4 and 5 and you should get the message "You're already running the latest Xdebug version".
So far so good!

You now have PHP and its debugger installed.
Now on to gettng it to work within eclipse>>.

No comments:

Post a Comment