How can I get XDebug to run with PHPUnit on the CLI?

后端 未结 9 1997
时光取名叫无心
时光取名叫无心 2020-12-23 11:01

I\'ve tried running the following CLI command:

phpunit -d xdebug.profiler_enable=on XYZTestCase.php

but it just runs as normal. Can anyone

9条回答
  •  猫巷女王i
    2020-12-23 11:17

    First, my environment:

    • WampServer Version 3.1.3 64bit
    • Apache 2.4.33 - PHP 7.1.16
    • MySQL 5.7.21
    • MariaDB 10.2.14

    php.ini:

    [xdebug]
    zend_extension ="c:/wamp64/bin/php/php7.1.16/zend_ext/php_xdebug-2.6.0-7.1-vc14-x86_64.dll"
    
    xdebug.remote_enable = 1
    xdebug.remote_autostart = 1
    xdebug.profiler_enable = 1
    xdebug.profiler_enable_trigger = 1
    xdebug.profiler_output_name = cachegrind.out.%t.%p
    xdebug.profiler_output_dir ="c:/wamp64/tmp"
    xdebug.show_local_vars=0
    xdebug.idekey = "PHPSTORM" #seems to work without this too
    

    phpunit.xml:

    
    
        
            
                ./tests
            
        
        
            
                ./app
            
        
        
            
            
            
            
        
    
    

    I made a test run configuration on phpstorm like this:

    After making run configuration, the below command was run when I clicked debug button in PHPSTORM.

    C:\wamp64\bin\php\php7.1.16\php.exe
    -dzend_extension=C:\wamp64\bin\php\php7.1.16\zend_ext\php_xdebug-2.6.0-7.1-vc14-x86_64.dll
    -dxdebug.remote_enable=1 -dxdebug.remote_mode=req -dxdebug.remote_port=9000 -dxdebug.remote_host=127.0.0.1 C:/wamp64/www//vendor/phpunit/phpunit/phpunit --bootstrap C:\wamp64\www\\vendor\autoload.php --configuration C:\wamp64\www\\phpunit.xml --teamcity
    

    Please notice the --teamcity. I have no idea about it :) Also notice the back and forward slashes.

    I hope this helps everyone.

提交回复
热议问题