Configuring Xdebug for using zero-configuration debugging in Intellij - php

I'm using Intellij IDEA 2016.3.3 with the PHP-plugin of PhpStorm in Linux Mint 18. I try to configure Xdebug for using zero-configuration debugging. I followed the official guide and this video tutorial. However, the debugger does not stop at any breakpoint.
/opt/lampp/etc/php.ini (extract)
[Xdebug]
zend_extension = /opt/lampp/lib/php/extensions/no-debug-non-zts-20151012/xdebug.so
xdebug.default_enable=1
xdebug.idekey=Intellij
xdebug.remote_enable=1
xdebug.remote_port=9000
xdebug.remote_connect_back=1
I generated Xdebug & Zend Debugger bookmarklets with IDE key Intellij.
Workflow:
Intellij: Run > Start Listening for PHP Debug Connections
I open a PHP-file of my PHP-project in Intellij that I'd like to debug.
I add a breakpoint
I open the file in the browser by clicking on the Google Chrome icon in the top-right corner
I click on the Start debugger bookmarklet in Google Chrome
I reload the page
I expect the debugger to stop at the breakpoint, but it doesn't

I'm not sure what I did, but it suddenly works. I did a restart of Intellij and now it works. I guess that I only did a reload of php.ini in the PHP settings after a relevant change of php.ini, but that didn't affect the build in web server.
#LazyOne Thank you very much for your help and patience.

Related

PhpStorm won't debug

I've installed PhpStorm hoping to debug a WordPress site running on my workstation on top of Local (https://localwp.com), which comes with an "Xdebug + PhpStorm" plugin I have installed.
The "zero configuration" has not worked for me. I set breakpoints and request a page in the browser but the breakpoints never get hit.
What else do I need to make this work?
Appendix I
PHP version 7.3.5
PhpStorm 2020.1.3
php.ini
[xdebug]
zend_extension = /Applications/Local.app/Contents/Resources/extraResources/lightning-services/php-7.3.5+8/bin/darwin/lib/php/extensions/no-debug-non-zts-20180731/xdebug.so
xdebug.remote_enable=1
xdebug.remote_connect_back=Off
xdebug.remote_port="9000"
xdebug.profiler_enable=0
In order for PhpStorm / Local / Xdebug combo to work, you'll need to
Start Local
Install the addon for Xdebug from within Local
Restart Local
Start a site in Local (ie test)
Go to Utilities and click "Add run configuration to PhpStorm" (ignore the error that'll pop up)
Start PhpStorm and open ~/Local Sites/test/app/public/app/public . THAT'S IMPORTANT to open the public folder (that contains your WP root)
You'll see a "LOCAL" xdebug dropdown on the top right in PhpStorm
You're all set!
open /app/public from within PhpStorm

Symfony 3: Debugging with Symfony's development server

During the development on a Symfony 3.3 project I use the Symfony's internal server as seen there But I cannot figure out how to use the xdebug in order to debug it. I mean I have installed and configured xdebug via:
apt-get install php-xdebug
And I export:
export XDEBUG_CONFIG="idekey=phpstorm"
But when I put a breakpoint to my IDE and I enable the xdebug via that plugin I still get no response.
Also I have put the following settings on /etc/php/7.0/mods-available/xdebug.ini
zend_extension=xdebug.so
xdebug.remote_enable=On
xdebug.remote_autostart=On
xdebug.remote_handler=dbgp
xdebug.remote_host=localhost
xdebug.remote_port=9021
xdebug.remote_mode=req
And I have configured both PhpStorm to listen over port 9021. But I still get the problem that I cannot make PhpStorm to listen over a breakpoint.
Do you fellows have any sort of idea how I can fix that over my ubuntu-16.04 machine?
Furthermore I have looked on these questions without any success:
Xdebug configuration with PHP fastcgi and eclipse?
Is it possible to use Xdebug with the built in PHP test server?
EDIT 1
I also tried to export the following:
export XDEBUG_CONFIG="idekey=PHPSTORM"
An configuring the Firefox plugin but still get the very same behaviour. Also keep in mind that I made the PhpStorm to listen over xdebug by pressing the button.
EDIT 2
I also put the following configuration over my PhpStorm:
Still does not work.
In the end the following steps are needed:
Put the following content into: /etc/php/7.0/mods-available/xdebug.ini
zend_extension=xdebug.so
xdebug.remote_enable=On
xdebug.remote_handler=dbgp
xdebug.remote_host=localhost
xdebug.remote_port=9021
xdebug.remote_mode=req
Export:
export XDEBUG_CONFIG="idekey=PHPSTORM"
Then configure PhpStorm as the image shows.
Set as IDE key PHPSTORM into the Firefox plugin
Enable xdebug on Firefox via pressing the button. Alternatively you can append the url with ?XDEBUG_START part
Then press the button in PhpStorm. In case you see the then press it back again.
NOTE:
In case you change xdebug settings TERMINATE the xdebug session by pressing button and pressing back again.
Furthermore in case you run composer via terminal disable PhpStorm to listen xdebug by pressing button.

Using xdebug with PhpStorm

I can't get my PhpStorm IDE to work with xdebug.
My current setup is the following:
PhpStorm 2017.1.4
MacOS Sierra 10.12.5
Here are the steps that I followed.
I have installed php with the following command. I have added the postgres parameter because I need it later to connect to a PostgreSQL database.
brew install php71 --with-postgresql
The next step is to install XDebug with the following command
brew install php71-xdebug
So the next step that I got from the documentation (https://www.jetbrains.com/help/phpstorm/configuring-xdebug.html) is to edit the php.ini file with the following content:
[Xdebug]
zend_extension="<path to php_xdebug.dll>"
xdebug.remote_enable=1
xdebug.remote_port="<the port for Xdebug to listen to>" (the default port is 9000)
xdebug.profiler_enable=1
xdebug.profiler_output_dir="<AMP home\tmp>"
Just some questions about those fields and XDebug.
So I guess XDebug is some kind of service that runs on the remote_port and that PhpStorm is using to write data to? Or do you have to specify the port where the application you want to test is running?
What exactly is the profiler thing? And can the output dir be anything I can choose?
So this is my php.ini file that I think it should be:
[xdebug]
zend_extension="/usr/local/Cellar/php71-xdebug/2.5.4/xdebug.so"
xdebug.remote_enable=1
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.profiler_enable=1
xdebug.profiler_output_dir="/usr/tmp"
That's it for the php.ini. So I have to check the settings in my PhpStorm IDE. And those are the following:
So that is my setup. In my project I just have one index.php with <?php echo phpinfo(); ?> I just click the Chrome icon so it opens directly in the browser to check if XDebug is there. I see the following result.
So I thought to myself ok let's try some debugging. So I changed my index.php file to the following
$i = 2;
$j = $i + 2;
echo $j
I've put a breakpoint on the 2nd line. And when I run it, it never stops at the breakpoint. What is needed to do that or am I wrong in my configuration somewhere?
To make Xdebug remote debugging working on your page, you need to set a cookie in your browser, telling the server you want to debug the page, there are many extensions for that, the most known is Xdebug helper in Chrome.
I also suggest you to follow this tutorial Zero-configuration debugging, it is very detailed and clear IMO.
If you still have problems i'll try to help you with pleasure :)

Eclipse PDT + xdebug: step through code broken

I'm using PHP 5.6.2 with xdebug 2.2.5 and Eclipse 4.4.1 with PDT 3.3.1. I'm trying to setup the debugger (xdebug) on a local server (localhost) and something appears to be broken.
When I start a debugging session eclipse switches to the debug perspective and stops at first line (as checked in config). The problem is that although the debugger (in debug window) seems to follow the execution as I step through code (it shows code lines as it advances), the window below that opens the source file and shows the code remains on the first position like/breakpoint it hits. It seems to be disconnected from the debugger...
Does anyone knows how to fix the problem ? Is it me, or there is a bug in this ? It used to work with older php/eclipse combination. I've upgraded php to 5.6 in between, as well as all it's dependencies. Same for eclipse. It's hard to pin point the issue at this point.
I'm using nginx with php-fpm.
Xdebug config in php.ini
[xdebug]
xdebug.remote_enable=On
xdebug.remote_host="localhost"
xdebug.remote_port=9000
xdebug.remote_handler="dbgp"
This is a duplicate of xdebug breakpoints work but step over does not
You need latest PDT-nightly or downgrade to luna 4.4.0

Debugging php on ubuntu 9.04?

Is there any IDE (linux based) for PHP that can be used to debug? Or any one can help me to configure debug properties/settings of eclipse? Now i am using ubuntu 9.04. i have tried to debug but havn't tried to configure, because i don't know how to configure it. can you tell me the exact way? please help me.
I use ActiveState Komodo IDE 5 w/ xdebug & xdebug helper firefox extension.
** You can use most of the info below for any IDE that supports xdebug **
You need to add the xdebug information to your php.ini.
[xdebug]
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.extended_info=1
xdebug.idekey=
Then, in preferences->languages->php, go thru the debugger wizard. Next you must turn on "listen for debugging connections" in Komodo IDE under the Debug dropdown.
Setup the xdebug helper firefox addon and enter the required info in its config dialog for your debug server, restart firefox and click the icon in the lower right corner to begin using xdebug on a page.
I recommend Eclipse PDT with Xdebug.
You can also try Aptana (based in Eclipse) or NetBeans.
Working with NetBeans and PHP is really simple. ou can follow this tutorial
I am using PHPStorm with xdebug. Works quite well :)

Categories