You can use the Eclipse PDT Xdebug client to debug PHP
code.
Before you begin
The PHP Development Tools (PDT) 2.1 or higher must be installed in Eclipse to debug PHP code. For
more information, see www.eclipse.org/pdt/.
About this task
You can remotely connect an Eclipse debug client to dynamic
scripting applications. By using an Eclipse debug client, from your
workstation you can stop at breakpoints, step through your code, evaluate
expressions, inspect stack frames, and inspect variable values, while
the PHP code runs on z/OS®.
Procedure
- Configure Xdebug:
- In Eclipse, click
- Select XDebug.
- Click Configure.
- From the Accept remote session
(JIT) list, select prompt. From
the Capture stdout list, select off.
From the Capture stderr list, select off.
In the Debug port field, you can change the
port that is used by the debugger from the default of 9000, if necessary.
- Click OK, then click OK again.
- Create a PHP project that contains the files that you
want to debug.
- Open the file that you want to debug, and add breakpoints
in your PHP code by clicking in the gutter.
- In the Package Explorer pane in Eclipse, right-click your
OSGI web project, then click .
- Edit your liberty JVMPROFILE to add the following line,
replacing ip_address with the IP address of your
workstation, and port with the port number assigned
to Xdebug in Step 1.d (the
default port is 9000):
-Dp8.debug=idekey=ECLIPSE_DBGP&remotePort=port&remoteHost=ip_address
This
ensures that the dynamic scripting application starts debug support
in the PHP engine, and requests that it connects to the debug client
on your workstation.
- Start or restart your Liberty JVM server.
- Run the code that contains the breakpoint, for example,
by issuing an HTTP request to the appropriate URI. If you have a breakpoint
in /hello.php and the context root is /example,
you can run it by accessing http://hostname:port/example/hello.php in
a browser.
- Eclipse detects the remote request to debug and prompts
you to begin the debug session. Click Yes.
- Eclipse prompts you to map the file that is being run remotely
to a file in your workspace. Select the appropriate file and click OK.
- You can now step through the code and inspect the context,
including stack frames and variable values.
Results
You have used the Eclipse PDT 2.1 to debug a dynamic scripting
application.