Composer with XDEBUG - PHP

Asked

Viewed 567 times

3

I have XDEBUG installed in my PHP. In this scenario, when doing a Composer installation I get an error message about Runtime performance, according to the photo below:inserir a descrição da imagem aqui

My question is, what is the range of that performance drop? It would only be in the execution of Composer, when I’m downloading and installing dependencies or running PHP (which would be the most serious case)?

Here on the website of commiserate we have the instruction on how to disable the Xdebug, but it is not very clear whether it will be something permanent.

Someone’s had that problem before?

1 answer

1


Xdebug is not installed (enabled) in Composer but in PHP, there are two basic layers of php usage, the web (which can use several types of modules) and CLI (command line), in case Xdebug will only be useful in the module with Apache (such as PHP-FPM, Apache2handler or Fast-cgi) in the Composer it is totally expendable.

Xdebug is a tool for development, that is, Composer is not necessarily development, it is package manager, development will happen after installing the packages.

This message that appears is just an explanation that the performance can be affected in PHP executions, usually every installation via Composer depending on the package or application will take longer, but you may not feel this, or it varies from package to package.

In the case as this using Xampp then the configuration files are:

  • c:\xamp\apache\bin\php.ini used for Apache, ie the settings will be valid when accessing http://localhost/

  • c:\xampp\php\php.ini used for CLI/CGI, that is to type in the CMD php script.php these settings will be used, in case Composer uses the CLI.

Then open and edit the c:\xampp\php\php.ini using Sublimetext or Notepad++, do not use Windows Notepad.exe (known as Notepad) as it does not recognize line breaks, look for a line similar to:

zend_extension_ts="C:/xampp/php/ext/php_xdebug.dll"

or (very unlikely):

extension="C:/xampp/php/ext/php_xdebug.dll"

And comment on it by adding the ; at first:

;zend_extension_ts="C:/xampp/php/ext/php_xdebug.dll"

Note that these are examples, if not found use Ctrl+F in your text editor (sublimetext or Notepad++) and type xdebug, go looking until you find the .dll.

As I said, Xdebug is of no use to the composer, Xdebug is only used at the time you are writing your files.

If it’s not Xampp

You may be using another php+apache installation facilitator, in which case php.ini for CLI and Apache may be the same, in which case you can set up Apache to load a different php.ini, in case you copy your file php.ini that is in the PHP installation folder for a different folder, preferably the apache folder (assuming it is C:\apache\) and then edit the file named httpd.conf with sublimetext or Notepad++ (or another similar editor) and look for a line like this PHPIniDir, if its value is different from the php installation location is because there is already a php.ini only for apache and this process is dispensable, but if it is something like C:\php\ or C:\wamp\php\ then change the value to point to the new php.ini, for example:

PHPIniDir "C:/apache/"

This way you will have a php.ini only for apache and another only for PHP in CLI/CGI mode, as I said in php.ini for apache you can enable Xdebug and in php.ini that is in the same folder as php.exe you should disable Xdebug with the examples I mentioned earlier.

Installed via repository (linux or like-Unix)

On systems like linux sometimes the installation of PHP and Apache are done via repository and usually this way will already exist by default one php.ini for CLI and another for Apache, usually the path is /etc/php5/cli/php.ini, but sometimes the location is different, for this you can search using the following command in the terminal:

$ php -i |grep php\.ini

Source: https://stackoverflow.com/a/3057131/1518921

Or if you need more details:

$ php --ini

Source: https://stackoverflow.com/a/3057131/1518921

Then open the file with your text editor (for example vim, gpedit, leafpad, etc.) and look for a line that contains something similar to this:

zend_extension="ext/php_xdebug.so"

Or this:

extension="ext/php_xdebug.so"

And comment on her adding ; at first, getting something similar to this:

;zend_extension="ext/php_xdebug.so"

Completion

Ready, now Xdebug will be disabled for Composer, because it is really something that is not necessary, note that despite using Xdebug together with PHP with Apache, he shall only be used for development, on your production server (when putting the site on the air for people to use) should always leave disabled Xdebug on the online server (ie outside your machine)because it not only does not serve much on the production server it still consumes much affecting performance.

  • 1

    Correct, as you said yourself, I will only have Xdebug in the development environment, so do not worry me in the production. Actually I don’t even have Xdebug in production php. My doubt was in the production environment, how much would be affected by Xdebug. But it’s already clear. Thanks.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.