Open the active php.ini
file in the editor:
To enable Xdebug, locate or create the [xdebug] section in the php.ini file and update it as follows:
Remove or comment out the following lines in the php.ini file to disable the Zend Debugger and Zend Optimizer tools, which block Xdebug:
zend_extension=<path_to_zend_debugger> zend_extension=<path_to_zend_optimizer>
To enable Xdebug, find or create the [xdebug] section in the php.ini file and update it as follows:
[xdebug] zend_extension = "<path to php_xdebug extension>" xdebug.remote_enable = on xdebug.remote_host = localhost xdebug.remote_port = 9000 xdebug.max_nesting_level = 256 xdebug.remote_handler = dbgp xdebug.remote_autostart = 1
zend_extension
- define a path
when the Xdebug library installed.
xdebug.remote_enable
- this
switch controls whether Xdebug should try to contact a
debug client. You have to enable it to run debugging
session.
xdebug.remote_host
- specify
the host where the debug client is running, you can
either use a host name, IP address, or
'unix:///path/to/sock' for a Unix domain socket.
xdebug.remote_port
- specify
the port to which Xdebug tries to connect on the remote
host. Port 9000 is the default for both the client and
the bundled debugclient. As many clients use this port
number, it is best to leave this setting
unchanged.
xdebug.max_nesting_level
-
controls the protection mechanism for infinite recursion
protection. The value of this setting is the maximum
level of nested functions that are allowed before the
script will be aborted. This option is used when working
with large CMS and frameworks like Yii2, Drupal.
xdebug.remote_handler
- can
only be 'dbgp' to represent the debugger
protocol. The DBGp protocol is the only
supported protocol.
Xdebug.remote_autostart
- when
this setting is set to 1, Xdebug will always attempt to
start a remote debugging session and try to connect to a
client.
Save and close the php.ini
file.
Restart web server after changes.
Verify Xdebug installation by doing any of the following:
In the command line, run the following command:
php --version
The output should list Xdebug among the installed extensions:
Create a phpinfo.php
file
containing the following code:
<?php phpinfo(); ?>
Open the phpinfo.php
file in the
browser. The phpinfo output should contain the Xdebug
section: