Configure modes in Xdebug
Xdebug modes control which debugging features are available and are configured in your PHP configuration file.
Lesson Content
Xdebug has different operating modes which control what features are available. These modes are set in your PHP configuration file, php.ini.
You can locate your php.ini file by running:
php -i | grep php.iniLook for the line which shows the php.ini file location, which for me is:
/opt/homebrew/etc/php/8.3/php.iniOpen the file, and look for the xdebug.mode property. This property may not yet exist, in which case you can add it to the file.
You can make Xdebug available for debugging by setting this value to “debug”:
xdebug.mode=debugAnd you could also set multiple modes by separating them with commas, like so:
xdebug.mode=debug,trace,profileNote that there are a few modes which you can enable, including:
debug: Enables step debuggingtrace: Enables function tracesprofile: Enables profilingdevelop: Enables development aidsgcstats: Enables garbage collection statisticscoverage: Enables code coverage analysis
The most common mode is debug, which enables step debugging. Without this mode enabled, step debugging features won't work.
You can check your current Xdebug mode by again using grep, and searching for “xdebug.mode”:
php -i | grep xdebug.modeWhen you see the output, you'll notice two values displayed. The first is called the "local" value - this is what's currently active and in use. The second is the "master" value, which comes from your php.ini file. Sometimes these values might be different if something else is overriding your php.ini settings.
These overrides can come from a few places - maybe an .htaccess file, a .user.ini file, or even from your code itself using ini_set(). For most users working locally, these values will usually match, but it's good to know why they might be different.
You could also get the PHP settings by creating a PHP file with:
<?php
phpinfo();…and then look for the "xdebug.mode" setting in the output.
Remember that any changes to the php.ini file also require the web server to be restarted, so to be sure to restart your web server, otherwise the changes will not take effect.