Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP composer xdebug warning

Tags:

New to PHP. Working on a PHP project and have xdebug enabled to be able to debug my php applications. The production server does not have xdebug enabled because it is handled by another team. On my local machine, when I run composer it gives me a warning saying

You are running composer with xdebug enabled. This has a major impact on  runtime performance. 

I do not want to disable xdebug when I am developing. Just wanted to confirm that running xdebug in dev environment should have no impact on the composer installing libraries/performance of the app on the production server.

like image 787
user275157 Avatar asked Nov 25 '15 06:11

user275157


People also ask

How do I disable Xdebug in composer?

As of Xdebug 3, it is possible to disable the Xdebug completely by setting the option xdebug. mode to off , or by setting the environment variable XDEBUG_MODE=off . It is very easy to disable Xdebug just for composer, by aliasing composer . You can add the alias to your $HOME/.

How do I know if Xdebug is enabled?

ini file to add a configuration line to load Xdebug. You can check whether it did by running php -v . If Xdebug shows up with a version number, than you're all set and you can configure Xdebug's other functions, such as Step Debugging, or Profiling. If pecl did not add the right line, skip to the Configure PHP section.


2 Answers

I do not want to disable xdebug when I am developing. Just wanted to confirm that running xdebug in dev environment should have no impact on the composer installing libraries/performance of the app on the production server.

There is a huge impact of just loading Xdebug. It slows the Composer run down by 3x or 4x, even when the profiling feature is not enabled.

In other words: xdebug is invaluable for debugging, but increases the memory used and processing time of Composer.


How to disable Xdebug for Composer runs?

My suggestion is to write a little invocation helper for running Composer.

The helper is a bash or batch script calling PHP with a custom php.ini, especially configured for Composer. Lets call it: php.ini-composer.

You could copy your current php.ini and adjust it for the Composer run, by removing xdebug or commenting it out, like so: ;zend_extension = "/path/to/my/xdebug.so".

While you are at it: setting memory_limit=-1 is helpful, too.

The full command looks like so on Windows: php.exe -c php.ini-composer composer.phar %*

Just clone the idea for a bash script.


And you may find the full answer to your question in the Composer FAQ.

https://getcomposer.org/doc/articles/troubleshooting.md#xdebug-impact-on-composer

It was added/updated just a few hours ago.


Some alternatives (instead of using seperate ini file) are also mentioned here.

like image 194
Jens A. Koch Avatar answered Sep 22 '22 15:09

Jens A. Koch


Modern versions of Composer can work around having XDebug enabled by default for the CLI SAPI. It spawns a new PHP process with the XDebug extension disabled in case it is detected.

You can disable this behaviour by setting the following environment variable:

COMPOSER_ALLOW_XDEBUG=1 

Found this in the documentation: https://getcomposer.org/doc/articles/troubleshooting.md#xdebug-impact-on-composer

like image 32
ojrask Avatar answered Sep 22 '22 15:09

ojrask