phpstormsettingsxdebug

How to pass custom config options for xdebug settings in PhpStorm?


In order to solve another problem, I want to manually provide certain configuration options for the Run Debug configuration.

In PhpStorm, at

Settings > PHP > Debug > Settings

there is a flag for

Pass require configuration options through command line (still need to enable debug extension manually)

For troubleshooting purposes, I disabled that flag, yet I don't see where to add my custom configuration options instead.

How to add custom configuration options?

I want to provide custom values for the flags:

How to?


Solution

  • These config options are read through the php.ini within your WSL instance.

    Add this in your relevant php.ini or 20-xdebug.ini, e.g.: /etc/php/8.3/cli/conf.d/20-xdebug.ini:

    zend_extension=xdebug.so
    xdebug.client_host=xdebug://gateway
    xdebug.mode=debug
    xdebug.client_port=9003
    

    Addendum: I also had the use case to get xdebug working both on fpm and cli.

    The default is to create an ini template in:

    /etc/php/8.x/mods-available/xdebug.ini

    This will symlink the template file in the respective cli and fpm subfolder via:

    phpenmod -v 8.x xdebug
    

    (Replace x with your relevant minor php version.)


    Addendum 2:

    I also wanted to be able to trigger an xdebug session on cli via

    $ XDEBUG_TRIGGER=1 ./somePhpFile.php
    

    For that I added:

    xdebug.start_with_request=trigger
    

    to the xdebug.ini file.