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

后端 未结 9 1993
时光取名叫无心
时光取名叫无心 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条回答
  •  太阳男子
    2020-12-23 11:30

    Spent ages trying to get this to work. Think this may change my life though!

    I originally was trying to do this (i.e. run phpunit) inside a vagrant box but realised it was easier (and faster performance wise) running it outside the vagrant box.

    First off I used brew install php55 php55-xdebugusing homebrew on a mac (but your configuration may be different and it should still work). My site is a symfony2 project.

    I was trying to follow this: phpunit vagrant xdebug to get it working from inside a vagrant box (almost got there but with some issues).

    These settings worked for me (running site from a vagrant box, but phpunit outside vagrant box):

    #xdebug.ini (parent machine, not inside vagrant box).
    [xdebug]
    zend_extension="/usr/local/Cellar/php55-xdebug/2.2.6/xdebug.so" #this will be different on your machine and will probably already be set
    
    xdebug.max_nesting_level = 250 
    xdebug.default_enable = 1
    xdebug.idekey = "PHPSTORM" #seems to work without this too
    xdebug.remote_enable = 1
    

    Then running this at the command line (here I am using a download of phpunit instead of the one linked to in /usr/local/bin (which doesn't seem to work))

    XDEBUG_CONFIG="idekey=PHPSTORM" bin/phpunit -c app
    

    Or you can create a file called phpunit-debug (to store the XDEBUG_CONFIG environment variable) as outlined here: phpunit xdebug

提交回复
热议问题