NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
Debugging PHP and Flex with PhpED

Joined: 24 Jan 2006
Posts: 311
Reply with quote
Hi - this tutorial was put together by one of PhpED users - we will publish the link to his website when it is up in production (pretty soon). Here it goes - enjoy:

You've got AMFPHP installed and working as follows...
1. You're able to call a function & return a value in your AMFPHP php code using
the AMFPHP gateway.
2. You're able to call a function & return a value in your AMFPHP code using your
Flex code.

This tutorial was developed using Flex Builder 3; Apache 2.2 and PHP on
Windows XP.
My AMFPHP code is within a folder within the amfphp/services folder. AMFPHP is
within Apache 2.2/htdocs.

There is lots of room for customization in PhpED; file naming; directory
organization etc.
This is a straightline path to get a breakpoint to trigger in your php code when you
invoke it from your Flex code.


    1. Backup your Apache and PHP folders
    2. Download and install PhpED
    3. Launch PhpED
    4. In the Workspace panel on the left side of the screen

      a. Right click on 'New Workspace' and select 'New Project' to launch the 'Project
      Settings Wizard'
      b. Click 'Next >>'
      c. Select ' Web server (Apache or another) used for development is located on this
      machine'. Click 'Next >>'
      d. Navigate to your 'Document Root:'. In my case, using the standard Apache
      install, it is 'C:\Program Files\Apache Software Foundation\Apache2.2\htdocs'.
      Click 'Next >>'
      e. Click 'Next >>>' on the 'Enter project root directory' leaving the 'Root
      directory' as is and the 'Add extra directories...' unchecked.
      f. Click 'Next >>>' on the 'Checking php installation' leaving the 'Check php
      installation' and 'Check for the latest...' as is.
      g. If all is well, the next step of the wizard should be all green checkmarks - it
      Try cancelling the wizard; quit PhpED; stop; start Apache and go back to step 4.
      If you're not getting all green checkmarks, you may wish to check the forums or
      contact Nusphere support.
      h. If all green check marks on 'Checking php installation', click 'Next >>>'
      g. Click 'Next >>>' on 'Checking debug session' leaving 'Check debug session' selected
      h. If all is well, the next step of the wizard should be all green checkmarks, if
      not, try the remedial steps suggested in step g
      i. Click 'Finish'
      j. Click 'Save' to save your project - likely called 'project1.ppj' (it is saved in
      the PhpED projects folder)
      h. Right click on the 'New Workspace' icon in the Workspace panel to save your
      workspace - for now call it 'workspace1'

    Save it on your desktop or other folder so you can double click it to launch.

    You'll want to have it handy so you can have PhpED running before you launch your
    Flex debugging session.
    5. Stop and start Apache to ensure changes Wizard made to php.ini take effect.
    6. You should now see 'project1' under 'workspace1' and if you expand project1 you
    should see the htdocs directory tree.
    Navigate to your code in the amfphp/services folder. If you can't find it, you'll
    need to remedy this before continuing.
    7. Under the the 'Tools/Settings' menu, select 'Run & Debug' in the left panel.
    In the right panel, clear the 'Stop on the first line after run' if it is set.
    If you don't clear this, each time your Flex app invokes AMFPHP, PhpED will stop in
    8. In the same 'Settings' dialog, select 'IDE/Associations' in the left panel.
    In the right panel, select 'HTML', click 'Edit' and delete ',*.html'
    In the same right panel, select'PHP5', click edit and add ',*.html' to the list of
    9. CLick 'OK' to save the settings changes made in steps 7 & 8 above.
    10. Navigate to a file in your directory under the Workspace panel, open it, and
    place a breakpoint on a line (click on line number) in a function that you'll call
    from your Flex code.
    The line should be highlighted and a red dot should be to the right of the line

    Aside - select IDE shortcuts under IDE in the left panel of the settings dialog,
    scroll the right panel down a bit and you'll see the function key shortcuts for the
    debugger - these can be remapped - but do that once you've got breakpoints working.


    1. Edit you 'services-config.xml' file.
    2. Navigate to around line 17 where the XML reads '<endpoint uri="http://localhost...'
    3. Change this line so instead of '...amfphp/gateway.php"
    it reads ...amfphp/gateway.php?DBGSESSID=1"
    4. Save this file and do a 'Clean' on your Project to ensure the changes are in effect.


    1. Launch your Flex application as you normally would from the IDE and cause it to
    invoke the PHP code where the breakpoint is set.
    2. PhpED should now flash in the task bar indicating that your breakpoint has been
    Activate the PhpED window.
    Hit F9 to continue. (Aside - F9 in PhpED is like F8 in Flex)
    3. PhpED has similar functionality to Flex Builder so you can inspect locals,
    globals, step through code etc
    4. On each call from Flex to AMFPHP you get a couple of lines in the PhpED log file
    indicating the debug session has started and completed: the breakpoint remains until
    you clear it


    1. If you're unable to hit the breakpoint from your Flex code, try invoking your php
    code from the AMFPHP service browser.
      The same breakpoints can be hit from there without the FLEX IDE.
      If you can hit your breakpoints this way, then check that your
      'services-config.xml' file is per above.

    2. If your breakpoint is still not being hit - try the following...
      a. In PhpED 'Tools/Settings' menu, select 'Run & Debug' in the left panel and SET
      the 'Stop on the first line after run'. Click 'OK'
      b. Run the AMFPHP sample code - you should get a breakpoint firing in 'gateway.php'
      c. If the above works the problem lurks somewhere in the your configuration of the
      FLEX IDE
      d. If the above does not work - run through the PhpED project creation again,
      creating a new project with the same directory structure, ensuring you get a green
      check mark on all tests. If no checkmarks, try checking the PhpED forum or
      contacting support.

    3. Ensure you have a fault handler to receive FaultEvent's within Flex. The handler
    will fire if you did not have PhpED running before trying to run in Flex.
    4. To run without PhpED, remove the '?DBGSESSID=1' parameter in your
    'services-config.xml' file.
View user's profileFind all posts by yfaktorSend private message
Debugging PHP and Flex with PhpED
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

 Reply to topic