Xdebug with VS Code on ubuntu not working - php

I am trying to debug php using xdebug on ubuntu 16.04 with Visual Studio code. I installed xdebug as per the instructions from the following site-Xdebug wizard. In the xampp the php version is shown as PHP Version 5.5.6 but when i run the command php -v in terminal, it shows
PHP 7.0.15-0ubuntu0.16.04.4 (cli) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
with Zend OPcache v7.0.15-0ubuntu0.16.04.4, Copyright (c) 1999-2017,
by Zend Technologies
I don't know if that may cause any problem. But, the real issue is that Debugger doesn't stop at any breakpoints. Also, it sometimes shows unverified breakpoint message. Sometimes it just runs and never stop at any breakpoints. The Xdebug options don't fully show up in phpinfo() page even after the installation. I don't understand the problem.

make sure you have configure xdebug.ini file. here mine.
[xdebug]
zend_extension=xdebug.so
xdebug.remote_autostart=1
xdebug.remote_log=/var/log/apache2/xdebug.log
xdebug.default_enable = 1
xdebug.remote_enable=1
xdebug.remote_port=9000

sudo apt-get install php-xdebug

Related

Xdebug not working on Mac (using PhpStorm)

I've recently had to swap over to a MacOS for development. Previously I had Xdebug running fine and it's such a massive help that I want to use is again.
I followed the Mac/homebrew instructions here: https://xdebug.org/docs/install#pecl with some more information that I found here: https://xdebug.org/docs/install#configure-php
php -v:
Cannot load Xdebug - it was already loaded
PHP 7.4.27 (cli) (built: Dec 16 2021 18:02:37) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Xdebug v3.1.2, Copyright (c) 2002-2021, by Derick Rethans
with Zend OPcache v7.4.27, Copyright (c), by Zend Technologies
In my php.ini (I double checked that it was the correct one) I appended
zend_extension=xdebug
I am running my site on a docker setup, and am using PhpStorm, here are the settings:
I have the Xdebug extension installed in Chrome and have made sure that PhpStorm is listening. However, when I put a breakpoint in my home controller and navigate to that page, the page loads without any breakpoints being hit.
phpinfo() also shows that xdebug is loaded:
I've noticed that the xdebug version shown in the phpinfo dump does not match the version of xdebug I downloaded and installed:

Debug session was finished without being paused

In my Laravel project using PhpStorm (2018.1) I am not able to debug my session using xdebug (2.9.5). Any breakpoint gets ignored and session ends without being paused. If I set Break at first line in PHP scripts then session stops at index.php file. I am using Ubuntu 20.04.
PHP 7.4.5 (cli) (built: Apr 23 2020 08:10:29) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Xdebug v2.9.5, Copyright (c) 2002-2020, by Derick Rethans
This are my settings for xdebug in php.ini
[xdebug]
zend_extension = /opt/lampp/lib/php/extensions/no-debug-non-zts-20190902/xdebug.so
xdebug.remote_enable=1
xdebug.remote_port=9001
xdebug.remote_log="/tmp/xdebug.log"
I have some PhpStorm settings:
What am I missing here?
I also have Xdebug helper extension in my Chromium but it seems to have the same effect with it enabled as well as disabled.
In my Laravel project using PhpStorm (2018.1) I am not able to debug my session using xdebug (2.9.5).
It just triggered:
PhpStorm 2018.1
Xdebug 2.9.5
You have to upgrade PhpStorm. You need PhpStorm 2018.3 or newer in order to be able to work with Xdebug 2.7 or newer.
The problem is in changed XML namespace in Xdebug protocol, as of Xdebug 2.7 (https instead of http). It's fixed/supported since PhpStorm 2018.3 (see WI-43622).
With your current IDE version you may work with Xdebug 2.6.x max (which does not support PHP 7.4).

Xdebug is installed, but the IDE does not listen to it

I am working on a project and I want to use Xdebug. So far, so good.
But I don't get that darn thing working and it is stressing me out (and also my colleagues)
I am using Laravel Homestead/Vagrant with PhpStorm as IDE. The Homestead VM is a Ubuntu VM (18.04.1 LTS)
The steps I've taken to install Xdebug.
I've to install xdebug on my Vagrant VM, it is also loaded when you start PHP and compiled with it.
php --ini
...
/etc/php/7.2/cli/conf.d/20-sysvshm.ini,
/etc/php/7.2/cli/conf.d/20-tokenizer.ini,
/etc/php/7.2/cli/conf.d/20-wddx.ini,
> /etc/php/7.2/cli/conf.d/20-xdebug.ini, <
/etc/php/7.2/cli/conf.d/20-xmlreader.ini,
/etc/php/7.2/cli/conf.d/20-xmlwriter.ini,
/etc/php/7.2/cli/conf.d/20-xsl.ini,
/etc/php/7.2/cli/conf.d/20-zip.ini,
/etc/php/7.2/cli/conf.d/25-memcached.ini,
...
php -v
PHP 7.2.13-1+ubuntu18.04.1+deb.sury.org+1 (cli) (built: Dec 7 2018 08:07:36) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.13-1+ubuntu18.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies
with Xdebug v2.6.0, Copyright (c) 2002-2018, by Derick Rethans
with blackfire v1.24.0~linux-x64-non_zts72, https://blackfire.io, by Blackfire
I've been to File / Settings / Languages & Frameworks / PHP
This is the settings of my CLI Interpreter
This is the settings of Debug
And this is my config file
zend_extension=/usr/lib/php/20170718/xdebug.so
xdebug.idekey="PHPSTORM"
xdebug.remote_enable=1
xdebug.default_enable=1
xdebug.remote_connect_back=1
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
xdebug.max_nesting_level=300
xdebug.scream=0
xdebug.cli_color=1
xdebug.show_local_vars=1
How can I solve the problem that when I try to go to my website, the debugger does not work (PhpStorm is listening to incoming connections and I am using a Firefox plugin for Xdebug)

PhpStorm xdebug configuration for php

After installing Xdebug on Windows 10 and test that with php --version command I get this output:
C:\xampp\htdocs\instacheeta>php --version
PHP 7.2.4 (cli) (built: Mar 28 2018 04:46:46) ( ZTS MSVC15 (Visual C++ 2017) x86 )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Xdebug v2.7.0alpha1, Copyright (c) 2002-2018, by Derick Rethans
After that I enable debug mode in PhpStorm by clicking on: , enabling Firefox XDebug addons: and then make break point on PhpStorm I expect that work correctly and stop on my break points.
But there are one problem, when I opening Validate debugger configuration dialog I can't validate debugger configuration
UPDTAE:
My web app work on 8000 port with http://127.0.0.1 IP and my web app folder is in C:\xampp\htdocs\instacheeta path
PROBLEM RESOLVE
i cahnged xdebug setting into php.ini to:
zend_extension=xdebug
[XDebug]
xdebug.remote_autostart=1
xdebug.default_enable=1
xdebug.remote_host=127.0.0.1
xdebug.remote_connect_back=1
xdebug.remote_enable =1
xdebug.remote_port=9000
xdebug.idekey=PHPSTORM
and adding PHPSTORM IDE key on PHPStorm settings from settings->PHP->Debug->DBGP

Installing xdebug with PHP 5.5

I've read quite a lot answers but couldn't figure out why xdebug doesn't work.
php.ini:
[xdebug]
zend_extension="/usr/lib/php5/20090626/xdebug.so"
php -v:
PHP 5.5.6-1+debphp.org~precise+2 (cli) (built: Nov 21 2013 14:31:41)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2013 Zend Technologies
with Zend OPcache v7.0.3-dev, Copyright (c) 1999-2013, by Zend Technologies
/usr/lib/php5/20090626/xdebug.so does exist. No zend optimizer in php.ini.
Also if I try to install xdebug:
pecl/xdebug is already installed and is the same as the released version 2.2.3
install failed
Thanks in advance.
Ok so I've stumbled upon this myself.
First of all, the 20090626 lib is compiled for php 5.3. So you can't really use that. Here are the steps I've performed in order to be able to use xdebug with php 5.5:
Download the source via xdebug download page.
Follow this guide for compiling your source into lib.
So now the extension is in correct source folder: 20121212, and you need to enable xdebug in your config.
I'm on ubuntu 12.04, so next steps might not work with your system:
create 20-xdebug.ini config and copy it to both /etc/php5/apache/conf.d and /etc/php5/cli/conf.d folders (if you plan on using xdebug in your cli of course). Insert next line of code there: zend_extension=xdebug.so
enable xdebug in both apache2 and cli php.ini configuration files:
xdebug.remote_enable = 1
xdebug.renite_enable = 1
xdebug.max_nesting_level = 1000
xdebug.profiler_enable_trigger = 1
xdebug.profiler_output_dir = '/var/log'
See more about xdebug settings: http://xdebug.org/docs/all_settings
php -v:
PHP 5.5.7-1+sury.org~precise+1 (cli) (built: Dec 12 2013 21:37:40)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2013 Zend Technologies
with Zend OPcache v7.0.3-dev, Copyright (c) 1999-2013, by Zend Technologies
with Xdebug v2.2.3, Copyright (c) 2002-2013, by Derick Rethans
Since this seems to bother more and more people trying to install xdebug via pecl here are the options:
Windows: Get the binary
Ubuntu (>12.04): sudo apt-get install php5-xdebug
Linux (other): via package manager or compile the latest source
Using PECL to install X-Debug for PHP5.5 as #Slayer Birden also answered will not work up to now and I don't think it will change in the near future.
I had a similar problem on Ubuntu 14.10. I forgot to enable xdebug:
sudo php5enmod xdebug
after installing xdebug from repository:
sudo apt-get install php5-xdebug
Also do not forget to restart web server
sudo service apache2 restart
My xdebug.ini looks like this:
zend_extension=xdebug.so
xdebug.remote_enable = 1
for xampp server first download xdebug and insert into php extention and edit php.ini file like this:
[XDebug]
; Only Zend OR (!) XDebug
; XAMPP and XAMPP Lite 1.7.0 and later come with a bundled xdebug at C:\xampp/php/ext/php_xdebug-2.3.1-5.5-vc11.dll, without a version number.
xdebug.remote_enable=1
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
; Port number must match debugger port number in NetBeans IDE Tools > Options > PHP
xdebug.remote_handler=dbgp
xdebug.profiler_enable=1
xdebug.profiler_output_dir="C:\xampp\tmp"
[PHP_XDEBUG-2.3.1-5.5-VC11]
zend_extension="C:\xampp\php\ext\php_xdebug-2.3.1-5.5-vc11.dll"
I ran into this problem today. Found out that the latest version on download page might actually not work. Download the one under Xdebug 2.3.0, select "PHP 5.5 VC11 TS (32 bit) (MD5: ef4a8994cef26c47ac891d6872e391b3)". It worked for me. I tried ver 2.3.3 and 2.3.2 before which did not work.
To install a very specific version of Xdebug for a specific version of PHP you can do it by compilation from sources. E.g. if you would like to compile xdebug-2.5.5 for PHP 5.6 run following commands in console (Ubuntu):
sudo apt install php5.6-dev
cd ~/Downloads
wget "https://xdebug.org/files/xdebug-2.5.5.tgz" -O "xdebug-2.5.5.tgz"
tar -xzf xdebug-2.5.5.tgz
cd xdebug-2.5.5/
/usr/bin/phpize5.6
./configure --enable-xdebug --with-php-config=/usr/bin/php-config5.6
make
sudo make install
All available versions of Xdebug can be found here. Xdebug compilation guide is here.

Categories