Accessibility

Table of Contents

Working with Flex and PHP in Eclipse

Debugging the code

You have the Flex and PHP code in place, and now you are ready to debug both. First you need to place some break points in the code. Add a break point in the second line of the getDataListener function in the Flex application, and another break point inside of the MyService PHP class, somewhere inside of the getData() method.

The next step is to start the Flex application in debug mode; select the flex_php.mxml file in Eclipse and click on the Debug button on the toolbar. Then, in the browser click Debug on the Zend Studio Toolbar. Next, click the button to the right of the Debug button and select All pages on this site (see Figure 16).

Start and setup the PHP debugger

Figure 16. Start and setup the PHP debugger

Now, you need to close the browser (this is an odd series of steps, but there seems to be a bug in Eclipse and I couldn’t find another workaround). Then, go back to Eclipse and start the Flex application in debug mode again. In the browser, click the Get data button.

This should start the PHP debugger in Eclipse. If you are asked to select the source for the zendamf_remote/index.php, just select the file from the wizard and click Finish. Here is another small oddity: the application is stopped, but it is stopped at a point before your break point. To work around this one, click Resume on the toolbar (see Figure 17) a couple of times, and you will get to the break point on the getData() method (see Figure 18).

The PHP debugger

Figure 17. The PHP debugger

The PHP debugger stopped at the break point.

Figure 18. The PHP debugger stopped at the break point.

At this point, you can see the values of the currently set variables, and when you click Step over (the button to the right of Resume) you can see the value of $ret as well.

When you’re finished looking around, click Resume again. The Flex debugger will start as the break point from Flex application is reached (see Figure 19). Now you can play in Flex to see the values of the event object including its event.result member. When you’re finished here, just click Resume again and the application will show its result message.

The Flex debugger at the specified break point

Figure 19. The Flex debugger at the specified break point

That’s it folks! It wasn’t so hard, was it?

Where to go from here

Using Flex Builder and Zend Studio for Eclipse together you can create combined Flex and PHP projects and take advantage of editing Flex and PHP files in this kind of setup. As your projects grow in scope and complexity, you will be able to debug the Flex and PHP code easily and at the same time.

Go to Flex Developer Center – Learn Flex and PHP page for more articles on Flex, PHP, and AMF.