I am trying to run php-cs-fixer with xdebug disabled. I found an old issue for Atom here: https://github.com/pfefferle/atom-php-cs-fixer/issues/27 but that suggestion no longer seems to work. If you run php with -n, you no longer have the phar extension. I then tried
php -n -d extension=phar.so /usr/local/bin/php-cs-fixer fix ... but then received errors about undefined constants.
I want xdebug enabled most of the time because I use it heavily while testing. Is there an easy foolproof way to disable it only when running php-cs-fixer?
$ php -v):=> 7.1.11
$ php-cs-fixer -V):=> 2.8.3
AFAIK there is no easy way to disable an extension on demand when running a PHP command. php -n will prevent loading all ini settings including extensions, but then you disable extensions that are required by PHP CS Fixer to run, which is probably the cause of the undefined constants errors you get.
I would suggest to disable Xdebug by default for CLI instead, and enable it on demand. You will speed up execution not only for PHP CS Fixer but any PHP command (Composer?), and slow down the ones that actually need it only. I published a little tool that might help you with that.
Composer has a piece of code that allows it to restart itself with Xdebug disabled. We recently rejected doing the same here (#3084) but now they are extracting this piece of code into its own package, maybe we could consider using it?
could be interesting, yet https://github.com/composer/xdebug-handler/issues/5 is must have to start using it.
It appears to be that composer/xdebug-handler#5 was patched on 20 Dec 2017. Can we move forward with this issue?
I'm having the same issue. Is there an easy solution by now?
yes. disable your xdebug globally and run it on demand only.
Well, that was easy 馃槄. phpdismod xdebug did the job for me on ubuntu. Thanks!
Most helpful comment
It appears to be that composer/xdebug-handler#5 was patched on 20 Dec 2017. Can we move forward with this issue?