I'm using PHPStorm and Xdebug. I'm trying to debug a Web Application Project configured in my localhost. There are no symbolic links in my project path.
Below is Xdebug configuration in my php.ini:
[Xdebug]
xdebug.remote_port=9000
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.profiler_enable=1
xdebug.remote_host=localhost
xdebug.remote_handler=dbgp
xdebug.idekey = "PHPSTORM"
xdebug.profiler_output_dir="/tmp"
xdebug.remote_log="/tmp/xdebug.log"
zend_extension=/usr/local/php5/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so
Below are two variables exported in my zsh:
export PHP_IDE_CONFIG="serverName=localhost"
export XDEBUG_CONFIG="idekey=PHPSTORM"
Below is server configuration:
Below is debug configuration:
Below is the screenshot of first breakpoint where I see no variable values.
Below is the screenshot after 'Step In'. It shows: Waiting for incoming connection with ide key 'PHPSTORM'.
I get below message in event log:
Debug session was finished without being paused.
It may be caused by path mappings misconfiguration or not synchronized local and remote projects.
To figure out the problem check path mappings configuration for 'dev.sales-crm.com' server at PHP|Servers or enable Break at first line in PHP scripts option (from Run menu).
My problem is: after debugging is started, then control stops at first breakpoint. It shows no variables values. Then If I try to 'step into', then debugging stops.
Please help me. Below is the link to xdebug logs: xdebug.log
I upgraded my Xdebug version form Xdebug 2.5.0rc1 to Xdebug v2.5.0 and it started working.
Thank you very much.
Related
i am trying to debug my php code in netbeans. the code runs perfectly but i am unable to debug it(doesn't stop at breakpoint) and the code runs normally.
i have tried every possible workaround in order to get my xdebug working and has been stuck from past few days.. anyone out there who can help me sort out this issue.
xdebug configuration in .ini file:
zend_extension = /usr/lib/php5/20090626/xdebug.so
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=mgiplocalhost
xdebug.remote_port=9000
here mgiplocalhost is my virtual host.
i have tried with other possibilities as well like localhost and ip address but the waiting for connection still exists.
In netbeans->tools->options->debugging when i set my port as 9000 and debug it asks me to change the port since port 9000 is already in use. i have changing the port but the problem persist.
please i need help to sort it out asap. please help me out.
A bit late but thought this should have an answer! To get Xdebug working, the minimal configuration I found I needed in the php.ini file was the line to load the extension:
zend_extension=php_xdebug.dll (pointing to the downloaded dll from the Xdebug site)
And the following Xdebug settings also placed further down in the php.ini file:
[Xdebug]
xdebug.remote_autostart=On
xdebug.remote_enable=On
xdebug.idekey="netbeans-xdebug"
The Xdebug default port was 9000, and that is also what Netbeans was using (Tools -> Options... -> PHP -> Debugging.) If 9000 is in use, you could also set that in Netbeans to be 9001 and in the php.ini file add the line xdebug.remote_port=9001 with your other xdebug settings.
Then try it out after restarting the server.
I have a Win7 on my laptop and a VMware Machine running Ubuntu.
On the last one I have my LAMP configured and also a samba server in order to be able to share my projects to Win7 (mapping a drive).
I just installed xdebug through a package manager and done the following configuration in the php.ini:
extension=xdebug.so
[xdebug]
zend_extension=/usr/lib/php5/20090626+lfs/xdebug.so
xdebug.remote_enable=1
xdebug.remote_connect_back=1
xdebug.remote_host=192.168.199.2 # this is my $_SERVER['REMOTE_ADDR']
xdebug.remote_port=9055
xdebug.show_local_vars=0
xdebug.var_display_max_data=10000
xdebug.var_display_max_depth=20
xdebug.show_exception_trace=0
Then I got through the following checklist:
confirm xdebug is installed using phpinfo()
got some marklets from here so I can easily send xdebug cookie
in PHPStorm->Settings->PHP->Debug I have set the 9055 port for xdebug
pressed the "phone icon" in PHPStorm in order to listen for incoming xdebug connection, and set debug key (same as the one sent by markets - 'xdebug')
moved to browser, accessed my script url, start a debug session using marklet (confirmed afterwords the presence of debug key in phpinfo())
marked a break point in my script
refreshed browser page
But nothing works for me.
Briefly, the fix for my problem was this:
enable xdebug.remote_log (where I could check for connection attempts and identify the exact IP to which xdebug was trying to connect) - [this was the key]
removed/set to 0 xdebug.remote_connect_back (because it overwrites remote_host with $_SERVER['REMOTE_ADDR'])
set the proper xdebug.remote_host
removed extension=xdebug.so an loaded xdebug using only zend_extension
So, every time, do not forget to check the logs if exists! :)
Thanks to LazyOne for very helpful hints!
I use PHPStorm along with Xdebug to step through my code. PHPStorm is running on a Windows 7 machine, and my local webserver is running on a separate CentOS 6.4 machine. I've done a phpinfo(); to verify that Xdebug is being loaded by PHP, and it is. The following are the settings for my Xdebug in the PHP.ini:
[xdebug]
zend_extension="/usr/lib/php/modules/xdebug.so"
xdebug.remote_enable = 1
xdebug.remote_port = 9000
xdebug.remote_host = "192.168.1.130"
xdebug.remote_log = "/var/log/httpd/xdebug_log"
I similarly setup PHPStorm to use my CentOS server as the debugging server, and I listen for connections. I assigned static IPs to both of these machines. Using a Chrome Xdebug plugin to set the appropriate cookies, I attempt to set a breakpoint, but nothing happens. When I go to look in /var/log/httpd/xdebug_log (which has 777 permissions), nothing is written there. I've opened up port 9000, and I can telnet from my CentOS machine back to my Windows machine on port 9000 no problem. I also set SELinux to permissive, but to no avail.
Any ideas what could be happening here?
Try to configure your project in PhpStorm
Open Settings->Languages & Frameworks->PHP->Debug
Uncheck the "Ignore external connections through unregistered server configurations" option
OK
Add to your php.ini:
xdebug.mode=debug
I was having the same issue, below are the steps I performed to resolve it:
Make sure you have xdebug installed and in php.ini uncomment xdebug.mode=debug
Open Settings->Languages & Frameworks->PHP->Debug, Assign Debug Port value, you can find this port from php.ini. In my case, it was 9002
Now Validate debugger configurations - here you need to add the path to your web application files and URL. Click validate.
Now Start Listening -> Enable listening for PHP Debug Connection.
After this setup you can set a break point and start debugging with XDEBUG.
In my case, i added folder that im debugging to exclusive, so it return 502 or blank page when i put breakpoint. Remove exclusive folder and everything working.
You can consider this blog to find more solution: Link.
sudo gedit /etc/php/7.2/mods-available/xdebug.ini
zend_extension=xdebug.so
xdebug.remote_enable = 1
xdebug.remote_port = 9898
xdebug.idekey = “PHPSTORM”
xdebug.show_error_trace = 1
xdebug.remote_autostart = 0
xdebug.mode=debug
xdebug.client_port=9898
I am trying to get Xdebug remote debugging to work, I am using PHPStorm as my IDE.
My webserver/code is hosted on a remote machine (amazon ec2).
I have the following lines in my php.ini on my remote server (PHP CLI since I am doing PHPUnit debugging)
zend_extension=/usr/lib/php5/20090626+lfs/xdebug.so
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.remote_handler = dbgp
xdebug.remote_mode = req
xdebug.remote_connect_back = 1
xdebug.remote_port = 9000
Since I am programming from my home network, I opened port 9000 on my personal router.
I have PHPStorm's xdebug server set to point to the remote server on port 80 with Xdebug as it's Debugger.
Now when I try to debug a PHPUnit test from PHPStorm it just says
'waiting for incoming connections with ide key '12115'
Except, it picks a random ide key every single time (I want to hope that PHPUnit is setting the idekey on the server itself)
I have been trying to get this to work for over 10 hours, I have tried defining my a specific remote_host in the php.ini instead of using remote_connect_back but that also did not work. I have tried setting an idekey in php.ini and that did not work as well.
Is there anyway to confirm that Xdebug is working as intended on the webserver side? How can I test my Xdebug settings without using Phpstorm, I don't know if it is a connection issue between my home network and the remote server or what.
Any guidance to help narrow down the issue would be great.
I know that the question is a little old, but since I had the same problem and just found a solution, I have decided to post here for anyone interested.
My solution is heavily based on the one provided by Rafael Dohms in
his blog post entitled: Debugging PHPUnit Tests in NetBeans with
XDebug
Environment
IDE: PHPStorm 6.0.2
Server: WAMP Server (32-bit & PHP 5.4.3) 2.2E
XDebug: 2.2.2
XDebug
zend_extension=c:\wamp\bin\php\php5.4.3\ext\php_xdebug-2.2.2-5.4-vc9.dll
xdebug.extended_info=1
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
xdebug.remote_log=c:/wamp/tmp/xdebug/xdebug_remote.log
The above configuration parameters go into the "php.ini" file for CLI. For the default WAMP installation, the full path to this file is: C:\wamp\bin\php\php5.4.3\php.ini
PHPStorm
First of all, you must create a "Server Configuration" (google "Creating a Server Configuration - JetBrains" for the official doc on the subject) specifying "Xdebug" as the "Debugger".
Then, create a new "PHP Remote Debug Configuration" (google "Creating and Editing Run/Debug Configurations - JetBrains" for the official doc on the subject) specifying the following values under the "Configuration" section:
Servers: the server created above
Ide key: PHPSTORM
Now, select that configuration and press the "Debug" button (or "Shift + F9"). PHPStorm will display the "Debug" panel and show the message: Waiting for incoming connection with ide key 'PHPSTORM'
Finally, "run" you PHPUnit test. There are several ways. One of them is:
Right click the name of the file the PHPUnit test resides in.
Select "Run file name"
That's it! XDebug will take control from here on.
If you're running Xdebug 2.2.0RC1, then the remote debug-log (http://xdebug.org/docs/all_settings#remote_log) will tell you succeeded and failed connection attempts. That might pinpoint whether the problem is on the Xdebug side, or phpstorm side.
In my case, the problem was that I had the xdebug config in /etc/php/fpm/php.ini, but php-cli uses /etc/php/cli/php.ini.
Since it took me a day to get it to work, I will sum up, what in learned:
Make sure, you are changing the right php.ini, XAMPP uses another php.ini and php version, than the one preinstalled on OS X Mavericks.
Define a logfile and if nothing is written into it, you a changing the wrong php.ini
In phpstorm you can validate your server connection and gain insight, if you are working on the right php.ini or what is still wrong.
You have to change settings for debug (might be worth to change the port to 9001), the server, all in phpstorm preferences and set up.
You have to set the php language level and the Interpreter (use the one your Apache mysql php configuration uses) e.g. /Application/XAMPP/xamppfiles/bin, click on ... to see Php and if debugger is attached. You might have to use another version of xdebug.
In Servers you have to define Host as
http://yourdefinitionofprojectonlocalhost
with usually Port 80 and Xdebug. Here it is essential to validate the remote environment.
Under debug you can set the Debug Port, if you change it to 9001, change it in the php.ini too, choose Can Accept external Connections.
If you do not enable Start to listen for PHP Debug Connection, you have no hope of getting it to work (Icon in upper right corner or down in Run menu).
In Edit Configurations... you have to define a PHP Web Application to be able to use Debug in the Run menu.
It took me a day to get it to work. The main issues being editing the wrong php.ini (do not forget to restart apache after edit) and the fact, that xdebug did not work with the php version.
As you can see I tried a lot of options in my php.ini and ended up using version of xdebug in found in my mamp directory:
;zend_extension="/usr/lib/php/extensions/no-debug-non-zts-20100525/xdebug.so"
zend_extension="/Applications/MAMP/bin/php/php5.5.10/lib/php/extensions/no-debug-non- zts-20121212/xdebug.so"
[xdebug]
;xdebug.var_display_max_children = 999
;xdebug.var_display_max_data = 99999
;xdebug.var_display_max_depth = 100
;xdebug.remote_enable = 1
;xdebug.remote_port=9001
;xdebug.profiler_enable=1
xdebug.remote_connect_back=0
;xdebug.remote_handler=dbgp
;xdebug.remote_host=localhost
;xdebug.profiler_output_dir=/Users/mypath/tmp
xdebug.remote_log=/Users/mypath/xdebug.log
;xdebug.remote_mode=req
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9001
Wish you more speedy success than I had.
In my case, it started working when I changed the port to something other than 9000.
Phpstorm's phpunit command was now:
/usr/bin/php -dxdebug.remote_enable=1 -dxdebug.remote_mode=req -dxdebug.remote_port=9002 -dxdebug.remote_host=10.0.2.2 /var/www/application/vendor/phpunit/phpunit/phpunit --bootstrap /var/www/application/tests/Bootstrap.php --configuration /var/www/application/tests/phpunit.xml <testfile> --teamcity
I have used XDebug semi-sucessfully with PhpStorm and Mamp, but now I want to try using NetBeans for a project. But I can't get NetBeans to connect to XDebug. It just waits until I stop the debugger and then I get a message that NetBeans never got a connection to XDebug, and it asks me to check the settings in php.ini.
Now, as I said it has worked ok with PhpStorm, so I don't think there should be anything wrong with the settings in php.ini, but anyway, here they are:
[xdebug]
zend_extension="/Applications/MAMP/bin/php/php5.3.6/lib/php/extensions/no-debug-non-zts-20090626/xdebug.so"
xdebug.remote_enable=on
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=localhost
xdebug.remote_port=9000
One thing that I found strange was that everyone talks about php.ini being located in /Applications/Mamp/conf, but in that folder there is no php.ini in my setup at least. In /Applications/Mamp/bin/php/php5.3.6/conf on the other hand, there is. So that's the one I have modified. And since it works in PhpStorm I figure it must be right...
But then, why isn't NetBeans able to connect? I'm also using the XDebug plugin for Safari to hook it up in the browser. And the port in NetBeans is set to 9000 as in the php.ini file.
I'm using NetBeans 7.0.1 and php5.3.6.
Anything else I'm missing?
EDIT:
Well, I found the problem for why XDebug wasn't connecting anyway: I am using the add-in for Safari for XDebug, and apparently it had it's own setting for IDE Key, set to 1, while NetBeans had netbeans-xdebug set. Once I changed it to the latter in the add-in I got a connection. The problem is I still get some sort of error. It says: 404 Page not found when I hit the debugger, and the address in the address field is: http://localhost/app_netbeans/index.php?XDEBUG_SESSION_START=netbeans-xdebug
Any idea what is going on here?
BTW, just hitting run inside NetBeans works fine and opens http://localhost/app_netbeans (I have used mod_rewrite to remove the index.php part of urls in CodeIgniter)
EDIT 2:
I found that the index.php part of the address was because in the run configuration in NetBeans there was an "index file" setting that was set by default to index.php. If I removed that to have CodeIgniter "controller" urls without the index.php I got the correct url, but with the xdebu stuff appended after it. But still I get the 404 Page not found when I use the debugger command, but not when I use the run command.
Weirdly enough what I can do is I can hit debug, ignore the fact that it goes to 404 Page not found, and go back to the IDE, hit run and if I have a breakpoint set it will then stop at that breakpoint.
But again, this is not exactly what I would consider normal debugging behaviour... So if anyone knows what is going on I would love to hear it...
Use this config and make sure you update Netbeans to use port 9001.
[xdebug]
zend_extension="/Applications/MAMP/bin/php/php5.3.6/lib/php/extensions/no-debug-non-zts-20090626/xdebug.so"
xdebug.remote_host=localhost
xdebug.remote_port=9001
xdebug.remote_enable=1
xdebug.idekey="netbeans-xdebug"
I found that the port 9000 sometimes conflicts with other applications, and xdebug seems to fail silently if it cant use it.
use the following code..
zend_extension="path to the xdebug.so"
;;;;;;;;;;;;;;;;;;;
; Module Settings ;
;;;;;;;;;;;;;;;;;;;
[xdebug]
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
and also make sure the port in the netbeans is correct. you can check that in
goto tools menu and select options
in options click on the php and check the port number.
Mine is finally working, so I wanted to post my full php.ini configuration:
[xdebug]
; got this script from https://netbeans.org/kb/docs/php/configure-php-environment-mac-os.html
xdebug.default_enable=1
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_host=localhost
xdebug.remote_port=9001
xdebug.remote_autostart=1
xdebug.idekey="netbeans-xdebug"
zend_extension="/Applications/MAMP/bin/php5.3/lib/php/extensions/no-debug-non-zts-20090626/xdebug.so"
xdebug.remote_log="/Applications/MAMP/logs/xdebug_remote.log"
You may also check if your project is configured to copy to a different directory in the Netbeans project settings. After I changed this setting I had to restart Netbeans and MAMP using the quit command.
Just to note:
No index.php in my start up properties
Stop at first line is turned off in debugging preferences
I do think changing to port 9001 made a difference on my system