I'm trying to enable Xdebug. I'm working on Ubuntu and I have trial PhpStorm version 2021.1.1.4.
My PHP version is 7.4:
PHP 7.4.21 (cli) (built: Jul 1 2021 16:09:41) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.21, Copyright (c), by Zend Technologies
with Xdebug v3.0.4, Copyright (c) 2002-2021, by Derick Rethans
In file: /etc/php/7.4/cli/conf.d/20-xdebug.ini I have settings:
zend_extension=xdebug.so
xdebug.idekey=PHPSTORM
xdebug.default_enable=1
xdebug.remote_enable=1
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
Symfony application is running on port 8000 and PhpStorm is listening debug like on the screen below:
I have also switched on the Xdebug Chrome extension:
What could be wrong? Why it doesn't stop on breakpoint?
EDIT:
Below I paste result of xdebug_info():
I was in the position as you, 3 months ago. Let me explain what i followed and got XDebug working. First of all download the latest version of Xdebug by copying and pasteing the output of your phpinfo() function https://xdebug.org/wizard
If you are on windows you need to place the .dll files of Xdebug in the php folder of your local server. Then open your php.ini and place the following lines at the bottom:
[xdebug]
zend_extension= <THE ABSOLUTE PATH TO THE XDEBUG FILE>
xdebug.mode=debug
xdebug.remote_enable=1
xdebug.client_host=127.0.0.1
xdebug.client_port=9003
xdebug.start_with_request = yes
xdebug.discover_client_host = 1
After you do that, open phpstorm on the settings/preferences tab go to the PHP Tab, go to the Xdebug section and enter Debug port 9000,9003, make sure can acept external connections is checked allong with the 3 checkboxes below from the Bebug port textfield.
Final step,close the settings window and at the top right corner of phpstorm press the red telephone icon to start listening for incoming connections.
Refresh your browser and phpstorm should pop up a windows prompting you to accept the debug session.
I hope this helped you a lot.
Related
I have installed php-debug in Atom + its IDE dependencies. When I set a breakpoint the debug view opens saying The debugger is not attached, but when I am trying to do so it seems as if Atom doesn't recognize I have php-debug package installed and asks me to install a debugger.
I read on some places there is a toggle debugging setting on the package, but I can't see that option.
I'm using Atom 1.27.0 and PHP 7.2.4:
PHP 7.2.4 (cli) (built: Apr 12 2018 02:49:03) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Xdebug v2.6.0, Copyright (c) 2002-2018, by Derick Rethans
with Zend OPcache v7.2.4, Copyright (c) 1999-2018, by Zend Technologies
I could provide Xdebug configuration but seems like the problem is on Atom itself? Did anyone have this problem?
very simple
Download xdebug from https://xdebug.org/download.php, TS version for Apache
Copy it to php/ext directory
Copy below text in php.ini below all other extensions
zend_extension="D:/wamp/php/ext/php_xdebug-2.6.1-7.2-vc15-x86_64.dll"
[xdebug]
xdebug.remote_enable=1
xdebug.remote_host=127.0.0.1
xdebug.remote_connect_back=1 # Not safe for production servers
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_autostart=true
Restart Apache and Find "xdebug" string in <?php phpinfo()?>
Install atom-debug_ui, php_debug
Package > PHP Debug > Toggle
Apply break-points and Run a PHP file from browser and that's it.
If it ask for paths remote http://localhost/DIRECTORY_PATH_TO_PHP_FILE
and local is directory path to PHP file.
I had the very same message few days ago …
Breakpoint were acually hit, I could see this because of the browser's tab loading icon, but nothing was happening on Atom user interface. All I could do was clicking stop or detach buttons which caused xdebug to end session and terminate browser tab load.
Using PHP7.2.7, Xdebug 2.6 (Docker php-fpm-alpine); Atom 1.26.1 x64
TLDR; PHP-debug extension couldn't process the "Path mappings" value I entered in the configuration panel.
Opening the dev console in Atom allowed me to spot an error accuring as the debugging session gets initiated in PHP Debug extension.
Atom Debug (PHP Debug) Session initiated
logger.js? [sm]:43 Atom Debug (PHP Debug) [TypeError: Cannot read property 'endsWith' of undefined
at Object.exports.generatePathMaps (/hom…]0: TypeError: Cannot read property 'endsWith' of undefined
at Object.exports.generatePathMaps (/home/me/.atom/packages/php-debug/lib/helpers.js:80:34)
at /home/me/.atom/packages/php-debug/lib/engines/dbgp/debugging-context.js:112:37
…
This led me to read at the Github repository and quickly figure what was going on.
All I had to do was changing the "Path mappings" text field value I erroneous filled in the first place. The text field expects a JSON string, as we can see HERE, the path mappings should be an iterable/array made of objects. It has to loook like this:
[{"localPath":"/home/me/projects/my-project","remotePath":"/var/www/my-project"}]
Add more mapping objects if you have more than one project. Note that this setting is reflected in ~/.atom/.config.cson
This fixed the issue, the debug view do not pop anymore saying there is no debugger attached.
I also had this problem, with Atom 1.53.0, PHP 7.3, and XDebug 2.9.8. I could tell from netstat that XDebug was connecting to Atom, but there was no activity in the PHP Debug tab, and no messages in the Console or PHP Console to give a hint of what was (or wasn't) going on.
Unlike Stphane, I didn't have any path maps defined. But taking a hint from his answer, I clicked on the "Path Maps" button in the PHP Debug tab. Then a series of error dialogs popped up, which I was able to solve one at a time.
In my case, the errors all happened because the project I'd checked out had some Unix symlinks in it, which Windows didn't know how to interpret. I solved them by removing the symlinks, and copying into their place copies of the files and directories they'd been pointing to. After that, the PHP Debug pane worked as expected - although the Debugger still says "No debuggers installed".
Atom Told me Debugger is not Attached but i made it work.
i saw atom php-debug tutorial but had problems like debugger is not Attached.
i want to share the configurations which that tutorial didn't includes:
Xdebug.ini autostart and idekey
first in the tutorial xdebug config. configs it to run automatic.
xdebug.remote_enable=1
xdebug.remote_host=127.0.0.1
xdebug.remote_connect_back=1 # Not safe for production servers
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_autostart=true
but its getting debugger run for every request. so you can make it off as this:
xdebug.remote_autostart=false
after that you have to tell debugger to send debug to atom`s api by appending this to xdebug config:
xdebug.idekey=xdebug-atom
if you use php-fpm, you have to reload it additional to restarting your http-server:
sudo systemctl reload php-fpm.service
Browser Extension with correct idekey parameter
after that install the browser plugin which attach a cookie to tell xdebug to made this request debuggable.
if your plugin hasnt Atom config,
in your browser extention preferences make this:
IDE key: xdebug-atom
Atom 2 plugins Enable and disable atom-ide-ui-feature-debug
and after that in Atom editor itself:
after installing atom-debug-ui and php-debug .
from Edit -> Preferences -> Package
select package atom-ide-ui package settings.
section Enable Features -> Enable Debugger
make it Never enabled .
like this:
https://github.com/gwomacks/php-debug/issues/310#issuecomment-419751273
True Break Points
now from Packages -> Debug -> Toggle Debugger
another note is when you want to make break point in atom. there are 2 types of break point. Big blue Dots and small blue dots.
only small ones work for debugger.
like here suggested:
https://learnwithdaniel.com/2019/06/atom-php-debugger/
Make remote path and local path identical
after setup request from browser. and Atom Asks you remote/local path.
make them identical
I've set up php 5.6 and Apache on my Mac and have IntelliJ with the php plugin installed (2016.2). The problem is that the IDE doesn't want to connect to the local server.
I've added the following lines to my php.ini:
[xdebug]
zend_extension=/usr/local/Cellar/php56/5.6.24/lib/php/extensions/no-debug-non-zts-20131226/xdebug.so
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.remote_port = "9000"
and when I run php -v I get:
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
with Xdebug v2.4.0, Copyright (c) 2002-2016, by Derick Rethans
and phpinfo() shows
xdebug.remote_enable On On
xdebug.remote_port 9000 9000
But IntelliJ shows:
xdebug.remote_enable 0
I've checked, that I'm pointing to the right php.ini (checked path and other changes appear when the file is edited).
I tried all configurations (including with an IDE key) but nothing seems to work.
Is there a way I can check if the debugging is really working (i.e. is it the IDE not recognizing something or is the server faulty), because at this point I don't know what the problem may be.
The best way is to collect xdebug log for such unsuccessful debug session to see what it has to say. Sometimes debug does not work for you (IDE shows no reaction) but xdebug actually connects somewhere just fine (e.g. another service .. as described below).
There is a chance that you will have php-fpm running on your computer (that depends on how you installed your PHP -- what tool you have used for that). Php-fpm by default uses the same TCP 9000 port as xdebug does.
sudo lsof -nP -iTCP -sTCP:LISTEN
Run this command in terminal -- it should tell (after filtering results on 9000 keyword) what services are already listening on that port.
If it's indeed php-fpm .. then changing xdebug port from default 9000 to any other (e.g. 9001 or any other usually unused port) in both IDE settings + php.ini will solve the issue.
When I run php --version (on CentOS release 6.4), I get:
# php --version
Failed loading /usr/lib/php/modules/xdebug.so: /usr/lib/php/modules/xdebug.so: cannot open shared object file: No such file or directory
PHP 5.4.19 (cli) (built: Aug 22 2013 08:03:53)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
with Xdebug v2.2.3, Copyright (c) 2002-2013, by Derick Rethans
What is the source of the "Failed loading /usr/lib/php/modules/xdebug.so: /usr/lib/php/modules/xdebug.so: cannot open shared object file: No such file or directory" message?
I confirmed the location of my php.ini file using:
# php -a
Failed loading /usr/lib/php/modules/xdebug.so: /usr/lib/php/modules/xdebug.so: cannot open shared object file: No such file or directory
Interactive shell
php > echo php_ini_loaded_file() . "\n";
/etc/php.ini
And then I searched /etc/php.ini for "/usr/lib":
# fgrep "/usr/lib" /etc/php.ini
zend_extension=/usr/lib64/php/modules/xdebug.so
extension_dir = "/usr/lib64/php/modules"
PHP doesn't seem to be configured (in the php.ini) to look for xdebug.so in /usr/lib/php/modules/. So why am I getting that error message?
Update: In response to Sverri M. Olsen's comment suggesting the path to xdebug.so might need fixing, I did:
# fgrep "xdebug" /etc/php.ini
zend_extension=/usr/lib64/php/modules/xdebug.so
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=vmhostmachine
xdebug.remote_port=9000
xdebug.profiler_enable=1
xdebug.profiler_enable_trigger=1
xdebug.profiler_output_dir=/usr/xdebug
xdebug.profiler_append=1
xdebug.auto_trace=1
xdebug.trace_format=1
xdebug.collect_params=4
xdebug.collect_return=1
xdebug.trace_output_dir=/usr/xdebug
xdebug.trace_output_name=trace.%H.%t
xdebug.profiler_output_name=profile.%H.%t
And I confirmed the above path to xdebug.so is correct:
# ls -lh /usr/lib64/php/modules/xdebug.so
-rwxr-xr-x 1 root root 200K May 21 2013 /usr/lib64/php/modules/xdebug.so
Note also that Xdebug works.
In GNU/Linux systems derived from modern Red Hat releases (such as RHEL, Fedora, and CentOS), the PHP distribution may be divided into the primary .ini file residing at /etc/php.ini as well as a collection of other .ini files specific to extensions or packages installed as RPMs residing in /etc/php.d. At initialization, PHP will read /etc/php.d/*.ini after loading the main php.ini file.
It would seem that you have a stale file containing Xdebug settings residing in /etc/php.d. Grep for Xdebug in /etc/php.d to find the offender and remove it or comment out the relevant lines.
grep xdebug /etc/php.d/*.ini
If Xdebug was installed separately by a manual process and you manually modified the main /etc/php.ini to load the extension and configure its settings, that would explain why Xdebug otherwise works while you still see errors about its nonexistence at /usr/lib/php/modules/xdebug.so. This also could have happened if configuration files from /etc were copied from an old 32bit system to a 64bit system wherein modules reside at /usr/lib64/php/modules
I am setting up xdebug with netbeans for my PHP application, hosted on a local xampp installation (Windows 7)
The installation and command line tests were successful and working correctly according to the netbeans / xdebug documentation. However, when I add a breakpoint in my code, it appears as a "broken" breakpoint no matter where I place it in the code. When I run the app w/ debugger, it fails to stop at these broken breakpoints.
I've done a lot of searching but haven't come across a good explanation for this, anyone out there have suggestions?
Thanks
Solution 1:
You need to configure the correct mapping between project source code and Xdebug output. you coudl do it here:
Project Window -> right click on project name -> Properties -> Run Configuration -> Advanced -> Path mapping
Solution 2:
Check in php info if xdebug is properly configured. You could check it by phpinfo() in empty php file and run it in browser:
<?php
phpinfo();
Try to find:
This program makes use of the Zend Scripting Language Engine:
Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies
with Xdebug v2.2.1, Copyright (c) 2002-2012, by Derick Rethans
Then in php.ini (you could check the location of this fiel in phpinfo() add this section:
[xdebug]
xdebug.remote_enable = On
xdebug.profiler_enable = On
xdebug.profiler_enable_trigger = On
xdebug.profiler_output_name = cachegrind.out.%t.%p
xdebug.profiler_output_dir = "c:/xamp/tmp"
xdebug.remote_handler=dbgp
xdebug.remote_port=9100
xdebug.remote_host=localhost
(make sure if this directory c:/xamp/tmp exists)
Then in netbeans in:
Tools -> Options -> PHP -> Debugging
Set:
Debugger Port: 9100
and select "Stop at First Line"
Save it and debug the applictaion it should work fine now.
I've been trying to configure this for quite some time now but I can't get it running properly. Done so far:
Downloaded the latest version of xampp and moved it to /opt/lampp
Installed php5-xdebug with apt-get
Changed implicit_flush to On in /opt/lampp/etc/php.ini
Added the following lines to the end of the ini file:
[xdebug]
zend_extension="/usr/lib/php5/20090626/xdebug.so"
xdebug.remote_enable=1
xdebug.remote_handler="dbgp"
xdebug.remote_port=9000
xdebug.remote_host="localhost"
I've made sure to restart apache, but I still don't get an xdebug-section when showing phpinfo();
I think that Eclipse is configured properly, but I can't know for sure until I get xdebug to run.
Please help, all suggestions are very welcome!
Edit:
Here is the output of phpinfo(): http://www.pasteall.org/35930
Update:
I've downloaded Xampp 1.8.1 (I had previously xampp 1.8.0) to /opt/lampp and added the appropriate development files. I have both compiled Xdebug myself according to the guide at http://xdebug.org/wizard.php and installed xdebug through /opt/lampp/bin/pecl.
Now my php.ini looks like this:
zend_extension = "/opt/lampp/lib/php/extensions/no-debug-non-zts-20100525/xdebug.so"
xdebug.remote_enable = 1
xdebug.remote_port = 9000
xdebug.remote_host = "localhost"
xdebug.remote_handler = "dbgp"
I don't know what to do, http://xdebug.org/wizard.php still reports that Xdebug isn't installed. Could it be a permission issue? Currently the permissions for the extensions are as follows:
-rwxr-xr-x 1 niklas niklas 88376 Sep 30 10:43 interbase.so
-rwxr-xr-x 1 niklas niklas 184920 Sep 30 10:43 oci8.so
-rwxr-xr-x 1 niklas niklas 118592 Sep 30 10:43 pgsql.so
-rwxr-xr-x 1 niklas niklas 830886 Oct 10 15:10 xdebug.so
Should they be owned by someone else? Must I enable any additional options in php.ini? This is my current output of phpinfo(): http://www.pasteall.org/36135
Tailored Installation Instructions
Summary
Xdebug installed: no
Server API: Apache 2.0 Handler
Windows: no
Zend Server: no
PHP Version: 5.4.4
Zend API nr: 220100525
PHP API nr: 20100525
Debug Build: no
Thread Safe Build: no
Configuration File Path: /opt/lampp/etc
Configuration File: /opt/lampp/etc/php.ini
Extensions directory: /opt/lampp/lib/php/extensions/no-debug-non-zts-20100525
Instructions
Download xdebug-2.2.1.tgz
Unpack the downloaded file with tar -xvzf xdebug-2.2.1.tgzRun: cd xdebug-2.2.1
Run: phpize
As part of its output it should show:Configuring for:
...
Zend Module Api No: 20100525
Zend Extension Api No: 220100525
If it does not, you are using the wrong phpize. Please follow
this FAQ entry and skip the next step.
Run: ./configure
Run: make
Run: cp modules/xdebug.so /opt/lampp/lib/php/extensions/no-debug-non-zts-20100525
Edit /opt/lampp/etc/php.ini and add the linezend_extension = /opt/lampp/lib/php/extensions/no-debug-non-zts-20100525/xdebug.so
Restart the webserver
http://xdebug.org/wizard.php
See below URL i think it is very help full to you
http://www.edmondscommerce.co.uk/ubuntu/ubuntu-xampp-xdebug-install/
http://www.webhelp2u.com/article/install-xdebug-on-lampp
https://stackoverflow.com/questions/9640912/problems-setting-up-eclipse-with-xdebug
Read it:-
Install XDebug on ( LAMPP OR XAMPP For Linux )
http://www.edmondscommerce.co.uk/ubuntu/ubuntu-xampp-xdebug-install/
http://www.webhelp2u.com/article/install-xdebug-on-lampp
To Install XDebug on LAMPP
Download the latest version of ( XAMPP For Linux ) From site http://www.apachefriends.org/en/xampp-linux.html
Install it. To install lampp, extract and put in /opt directory.
Download Development package from same site.
Extract it, copy and paste "include" folder from Development package to /opt/lampp directory. ( This package would use for compiling XDebug source )
Run command /opt/lampp/bin/pecl update-channels. this would update the pecl channels database at your local pc.
Run command /opt/lampp/bin/pecl install Xdebug. And wait for finishing the process.
Now xdebug.so file has been created in /opt/lampp/lib/php/extensions/ directory.
Now Open the file php.ini and add the line zend_extension="/opt/lampp/lib/php/extensions/path_to_xdebug.so". at the end of file.
Restart Lampp & Check enabled or not using phpinfo();
Update my answer after your comment
See below URL i think it is very help full to you.
Setup Xdebug for PHP5 in Ubuntu
http://gayanhewa.info/setup-xdebug-php5-ubuntu/
Since there is no sign of why it isn't working I've given up on xampp and just installed a regular lamp-server with xdebug through apt-get. I disabled mysql and apache2 from starting during boot so that they are not running if I don't want them. Here is a very simple tutorial on how to enable xdebug-debugging with Eclipse: http://www.web-brainz.co.uk/Xdebug
The other answers will surely be the most fitting for other users though they unfortunately didn't fix my issue. Thank you very much for help!
On a fresh ubuntu 12.04 run:
apt-get install php5-xdebug
Check for xdebug if it is installed:
php --version
it looks like this:
root#ubuntu-SandBox:/var/www# php --version
PHP 5.3.10-1ubuntu3.19 with Suhosin-Patch (cli) (built: Jul 2 2015 15:05:04)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies
with Xdebug v2.1.0, Copyright (c) 2002-2010, by Derick Rethans
root#ubuntu-SandBox:/var/www#
Modify your php.ini to load Xdebug run:
vi /etc/php5/apache2/php.ini
and add at the bottom of the file:
[xdebug]
xdebug.remote_enable=1
xdebug.remote_handler="dbgp"
xdebug.remote_port=9000
/* this is the ip address of your PHPstorm IDE machine. */
xdebug.remote_host="10.70.111.11"
Restart your server:
service apache2 restart
Now your server is ready for your client IDE machine to connect.
Here is how to configure PHPSTORM:
Follow this instruction of JetBrain https://confluence.jetbrains.com/display/PhpStorm/Validating+Your+Debugging+Configuration
or
On menu Run => Web Server Debug Validation and you will see something like this:
If you dont get the yellow and everything is blue you are good!
Install chrome extension xdebug helper from here:
https://chrome.google.com/webstore/detail/xdebug-helper/eadndfjplgieldjbigjakmdgkmoaaaoc?hl=en
Start a debug session in browser by enable this extension by click on it and the bug icon turns green.
Then in IDE Run => Listening for php debug connections.
Set a breakpoint in the source code
Load your php page (webapp) and it will be stopped at breakpoints.
Done.