PHP XDEBUG not getting enabled

17,855

Solution 1

I had same problem with XAMPP PHP7 now it's solved :) There should be missing or wrong extention file in your C:/php/ext/ directory.

This will solve your problem.

  1. Go to xDebug
  2. Dowload Xdebug 2.4.0rc1 (PHP 7.0 VC14 TS 32/64)
  3. Rename it to php_xdebug.dll
  4. Paste this file in "php/ext" folder
  5. Restart your server.

Now check your phpinfo()

In my case there were 64bit version so I've just changed to 32bit

Solution 2

Along with what @haider-lasani said please do not forget what type of PHP you are using. The latest XAMPP is using some really convoluted setup.

Go to your PHP folder and check whether you have php7.dll or php7ts.dll. If you have the latter version then you are supposed to pick up the TS version of xdebug. Also check VC version as well.In this case it is VC14. Now even though I am using a TS version of PHP I still have to add the plugin with zend_extension="C:/php/ext/php_xdebug.dll" and not zend_extension_ts="C:/php/ext/php_xdebug.dll"

TL;DR While downloading xdebug make sure you:

  1. Check x64/x86 bit version.(Use x86 xdebug just to be safe)
  2. Check what version of PHP you are using.
  3. Check whether you have TS or non-TS version of PHP by checking whether you have php{x}.dll or php{x}ts.dll.{x}is your php version.
  4. Try switching between zend_extension and zend_extension_ts to include your xdebug plugin in your php.ini file to see what works.

Following all these steps should ideally fix your problems. Let me know if you still are facing any problems. Peace.

Solution 3

You shouldn't need to rename your DLL and it is a good idea not to, as it allows you to see what build of XDebug you have running.

Here is what I did and it works:

This answer assumes you have PHP set up with the correct PATH entry so that you can run PHP from the Command Line such as GitBash https://git-for-windows.github.io/

  1. Open up your command line and enter this:

    $ php -i

  2. Scroll to the top and copy the output from the command line window beginning where you see

    phpinfo()

    ..... copy contents until you see the last line which ends:

    If you did not receive a copy of the PHP license, or have any questions about PHP licensing, please contact [email protected]. `

  3. Go the XDebug Windows Wizard https://xdebug.org/wizard.php and paste your PHPInfo in the big text box and submit.

  4. A new page will display with instructions and a "System Summary of your PHP. Carefully follow the instructions and select the Download link.

  5. Once you have modified your PHP.ini and observed where your "ext" folder is, copy your downloaded XDebug dll file to "ext" folder.

  6. Open your command line again and enter the following command:

    $ php -m

If you have correctly followed the instructions you will see the output contains the following:

[Zend Modules] Xdebug

Otherwise, you will see an error at the top of the console output such as: Cannot load Xdebug

Usually, the errors occur because your XDebug:

  • is not in the correct location
  • is the wrong version
  • is incompatible because of thread type: Your PHP maybe Thread Safe, and your XDebug is Not Thread Safe (the XDebug Wizard will automatically choose the correct version)

Solution 4

If you are doing remote development on either a WSL or a Linux, check your php directory as you may need to modify php.ini files in the following locations:

/etc/php/7.2/apache2/php.ini

and

/etc/php/7.2/cli/php.ini

with

[XDebug]
xdebug.remote_enable = 1
xdebug.remote_autostart = 1

;don't forget to change the path and filename to the correct one
;but make sure you use the full path

zend_extension="/usr/local/php/modules/xdebug.so"
Share:
17,855
Gary
Author by

Gary

I love coding and managing projects. Have an idea in mind? Lets connect for projects.

Updated on July 11, 2022

Comments

  • Gary
    Gary almost 2 years

    Unable to enable XDEBUG. Any help or check if it is enabled and not reflected? I am on PHP7 and am using Xdebug 2.4.0rc2. PHP.INI settings below:

    [XDebug]
    zend_extension="C:/php/ext/php_xdebug.dll"
    
    xdebug.remote_enable = on
    xdebug.remote_host = localhost
    xdebug.remote_port = 10000
    xdebug.remote_handler = dbgp
    xdebug.profiler_enable = 1 
    xdebug.profiler_enable_trigger = 1
    xdebug.profiler_output_dir = "profilerlogs"
    xdebug.profiler_output_name = cachegrind.out.%p
    

    Unable to get it enabled. The steps are right but doesnt show up installed in phpinfo() as well.

  • Gary
    Gary over 8 years
    I believe I did use the rc x64 version for php7 but did not work. In phpinfo() is not showing up. After installing debug browser extensions, it is setting the xdebug cookie but this is the error I get asexample Call to undefined function xdebug_break() . But my php -m does show xdebug in list of loaded extensions like @ins0 mentioned. Let me try using xampp installer and see if I can use it. May be my set up issues will get resoved. Let me try that and revert. Thanks.
  • Charles Blackwell
    Charles Blackwell almost 8 years
    it worked for me, thanks! I also had to use the 32bit ext even though i have a 64bit machine.
  • Gary
    Gary over 7 years
    @CharlesBlackwell hmm... thats strange. I had to install alternative extensions
  • Gary
    Gary over 7 years
    Yeah these are valid points. I can manage servers so I think I might not have missed these point but let me check again.
  • Carson Wood
    Carson Wood almost 5 years
    Changing from zend_extension to zend_extension_ts was my issue. Thanks!!