How to make a zend Debugger Enable with your Eclipse and Apache2

Installing Zend Debugger


Hello Friends,

I am adding this post only because i was not got easy way then this to remember what i have done .

q: why to use debugger ??

I think you must remember those days with the C and C++ when we need this one most . it's good to have a environment where you can get error easily and make it correct faster.

First you will need to install and configure the Zend Debugger:
  • Ensure you have the Eclipse PDT (PHP Development Tools) installed. If not: Add this repository to your sources list in Help > Install New Software...: http://download.eclipse.org/releases/helios

  • Expand the Programming Languages package and select PHP Development Tools (PDT) SDK Feature.

  • Click next and install.

  • Install the Zend PDT in the same way by adding this repository to your sources list: http://downloads.zend.com/studio-eclipse/updates/7_1

  • download your Zend Debugger from http://www.zend.com/en/products/studio/downloads

    • Expand Zend Studio Features and select Send Debugger Feature then click Next.

  • Restart Eclipse and then go to Window > Preferences > PHP > Debug > Installed Debuggers to ensure the Zend Debugger is installed.


  • Configure php.ini to point to the ZendDebugger.so file.

    • First type

      php5 -i | grep "Loaded Conf"

    into a terminal to find the correct php.ini file you need to edit and open it in a text editor

    • Next type

      locate ZendDebugger.so

    into a terminal and copy the location to the php5 Debugger file.

    • Add these lines to the bottom of your php.ini file:

      [Zend]
      zend_extension="[path to your ZendDebugger.so file]"
      zend_debugger.allow_hosts="127.0.0.1, [your IP address if required]"
      zend_debugger.expose_remotely=always
      substituting in the path returned from your locate command and your IP address.
  • Restart PHP by typing

    sudo /etc/init.d/apache2 restart

    into a terminal.

  • Then type the

    php5 -m

    command into your terminal to ensure the Zend Debugger is properly configured. You will see something like:

    xmlreader
    xmlwriter
    Zend Debugger
    zip
    zlib

    [Zend Modules] Zend Debugger

    near the end of the dump. If you don't see the Zend Debugger then make sure you have edited the correct php.ini file and ensure that the path to your ZendDebugger.so file is valid. Make sure to restart PHP for any changes to propagate.

just in case u got libssl.so 0.9.8 is not loaded then install the one.

apt-get install libssl0.9.8

and make a ZendDebugger.so readable with chmod a-x

best location to put ZendDebugger.so file is /usr/lib/php5/20090626/


Configuring Eclipse

Next you will have to configure Eclipse:

  • Firstly go to Window > Preferences > PHP > PHP Executables and make sure the latest PHP CLI libraries are installed and set as default.

  • Next add the PHP Debugging perspective in eclipse by going to Window > Open Perspective > Other > PHP Debug.

  • Now go to Window > Preferences > PHP > Debug and click Configure Project Specific Settings.

  • Select the project you want to debug and click OK.

    • Check the Enable project specific settings.

    • These are the settings you will need:

    PHP Debugger: Zend Debugger
    Server: [local URL path to your project (should configure this in hosts file)]
    PHP Executable: 5.3.x (or later)

    Default Base URL / Base Path: /
    Auto-generated Base URL: http://[local URL path to your project]
    • Uncheck the Break at First Line option and click OK to close the config window, then uncheck the same option on the main PHP Debug page. Click Apply to save the settings.

  • Next go to Window > Preferences > PHP > PHP Servers and add a New server config with the URL

http://[local URL path to your project]

this should be the same URL as in your host config that you use in dev' to get to your home page. Give the config a name and set it as default. Click Finish and OK then restart Eclipse.

  • Next go to Window > Preferences > General > Web Browser, select Use external web browser and choose a browser you want to interact with during debugging. >Note:> DO NOT USE FIREFOX! The Zend PDT binds to it and you cannot decouple the browser from the debugger without uninstalling and reinstalling firefox. The Opera browser works by far the best with the Zend PDT so here's how to add it:

  • After installing the Opera browser go to the Window > Preferences > General > Web Browser settings again and select New and use these parameters:

    Name: Opera
    Location: /usr/bin/opera
    Parameter: %URL%

    click OK, select Firefox if it exists and remove it then check Opera and click OK.

  • Restart Eclipse again and you will be ready to start debugging PHP.

Using the Debugger

  • In the PHP perspective open a PHP file and select Debug as > PHP Web Page either from the Project menu or by selecting the downward arrow beside the Debug icon.

  • You may see an alert window asking you to confirm the debug URL. Remove eveything after the base URL to leave just:

    http://[local URL path to your project]

    as the URL and click OK.

  • If eclipse doesn't switch to the PHP Debug Perspective automatically then switch to it manually.

  • Go to your browser and navigate to the URL you configured above. You may need to run the debugger forward for the homepage to resolve. Sometimes you will need to refresh and run the debugger forward a couple of times before it fully binds your debug session.

  • You can navigate site normally and the debugger will drop into your code at breakpoints.

Comments

Popular posts from this blog

Privacy Policy - StoryScribe

Privacy Policy - aXa Voice Command Assistant

StoryScribe