Download Summary

Transcript
Chapter 5
The above diagram illustrates the scenario of development workstation and
development web server being two physically different machines. To start things
off, the developer would open a web browser and request the page that is being
debugged from the server (marker 1). This typically happens over standard port
80. The web server then determines that PHP is responsible for generating the
requested page and hands processing off to the PHP executable (marker 2). This
might happen based on the file extensions that are associated with PHP, for example.
Within PHP, Xdebug figures out that it is supposed to start an interactive debug
session. The developer is able to communicate this request to Xdebug by including
an extra parameter in the URL. Now that Xdebug has claimed responsibility, it tries
to open a connection to the host and port, usually port 9000, listed in the Xdebug
configuration settings (marker 3). In this case, the machine running the debug client
is the developer's workstation, but that is not a requirement.
The remote debugger provided by Xdebug is most likely what you have come to
expect if you have used debuggers in other programming languages, such as C++ or
Java. It allows you to issue commands to step through the code one line at a time. At
any point, you can examine the variables and data structures that have been defined.
It also allows you to set breakpoints where code execution will stop and give you an
opportunity to evaluate and/or modify the state of the application before proceeding.
Remote server debug configuration
Before we can do any real remote debugging, we have to configure and enable that
feature in Xdebug. Here are the configuration settings that determine the behavior of
the debugger on the server:
Setting
Description
xdebug.remote_enable
Toggle remote debugger.
xdebug.remote_host
The host name or IP address
of the machine where the
debug client is running.
localhost
(localhost)
xdebug.remote_port
The port on which Xdebug
tries to connect to the debug
client.
9000 (9000)
xdebug.remote_handler
dbgp (dbgp)
The debug protocol
which Xdebug will use to
communicate with the debug
client. Valid settings are
php3, GDB, and the dbgp.
[ 241 ]
Download from Wow! eBook
www.WoweBook.com
Recommended
value (default)
1 (0) – as needed