Zend Debugger with Zend Server 5.6.0 & PhpStorm 5.0 - php

I am running Zend Server 5.6.0 which is PHP 5.4 and I am using PhpStorm 5.0. I am looking to put some profiling and debugging in place.
I have configured everything that I can see in PhpStorm, when I run the debug from the IDE it runs the script, then displays Connection with 'Zend Debugger' was not established. Validate Installation.
I have installed the toolbar but whenever I try to debug a page in Firefox it actually pops up with a download window and the file downloads, when opened it displays a server error.
All of the help guides online dont seem to work, has anyone else has these issues?

I ended up using Xdebug:
To Install Xdebug:
Go to webpage.
Paste your phpinfo() contents into the box
Follow the instructions on the wizard page except for where it tells you to add zend_extension = C:\Zend\ZendServer\lib\phpext\php_xdebug-2.2.1-5.4-vc9-nts.dll to the top!, put this below the iOnCube Loader (if you have it installed)
Add the following to php.ini then restart PHP & Apache.
php.ini
[XDebug]
xdebug.remote_enable=1
xdebug.remote_port=9000
xdebug.profiler_enable=0
xdebug.profiler_output_dir="C:\Zend\ZendServer\tmp\xdebug-profiler"
Xdebug in PhpStorm
Generate and add bookmarklets to your browser here (Note the IDE key ##PHPSTORM##)
Open File -> Settings -> PHP
Choose your interpreter
Click [..]and choose Debugger: Xdebug
Click the "Configurations" then Edit Configurations... item (Drop down next to debug button on toolbar)
Press the [+] to add a configuration and choose PHP Remote Debug
Call it Xdebug and use the IDE key PHPSTORM
You can now start the debugger (Alt+Shift+F9)
Start the debugger using the bookmarklet
You can now stop through code in PhpStorm, hope this helps someone

This is happening because PHPStorm is using the binary for php found under /usr/bin this is not the same one as Zend Server uses under /usr/local/zend/bin. On some systems like Mac PHP is already installed by default under /usr/bin but it will not interact with the Zend Server/Debugger.
To fix this all you have to do is go into the PHPStorm preferences and tell it to use the proper Interpreter. Click the ... button next to the Interpreter drop down and give it the path to zend's bin directory /usr/local/zend/bin
This solved the issue with PHPStorm debugging with the Zend Debugger.

Related

Xdebug 3 / PHP / VS Code / Win10 - Not opening in browser properly - any ideas what's wrong?

I've installed XAMPP (control panel 3.3.0) on my Windows 10 PC. I then installed VS Code (v1.74.3)
I ran the phpinfo() and pasted the results into the Xdebug wizard and followed the instructions on that page (downloaded php_xdebug-3.2.0-8.2-vs16-x86_64.dll, renamed as php_xdebug.dll and saved to C:\xampp\php\ext)
I then added the following to C:\xampp\php\php.ini file.
zend_extension = xdebug
I restarted the Apache server and VS Code. I also installed the PHP Debug (v1.30) extension to VS Code.
When I load up a test PHP file and try to debug it, it seems to work as expected in VS Code (it stops at breakpoints, I can step through, the variables pane updates, and echo'd text appears in the debug console. This is when I do "launch currently open script").
But when I do "launch built-in web server", to see what it looks like in a browser, it opens Chrome to http://localhost:62xxx/ (the number changes each time) and the page says:
Not Found
The requested resource / was not found on this server.
I've probably just missed a setup/config step somewhere. How do I get it to open a browser that shows what the script is outputting?

Xdebug configuration

I am new to php and I need to use Xdebug with netbeans for a remote school purpose.
My php's version is 7.3.21 and I am using it with Wamp. Netbeans is on 11.1 version.
I installed last updates for wamp and xdebug, and the problem is when i run debugger in netbeans, xdebug doesn't load and keeps this status running :
So I investigated and xdebug seems installed as you can see here (from click on wamp -> php -> configuration) :
and here (from click on wamp -> php -> extensions) :
Everything seems ok, but still doesn't work. So I check on https://xdebug.org/wizard with phpinfo() function, pasted the return in the textarea and here's the status :
I check everything and here is my php.ini file :
In this context, using the debugger shows me infos on a html page as you can see on following image but I can't inspect my variables in netbeans because of the "waiting for connection (netbeans-xdebug)...
I tried to use "localhost" instead of my IPv4 address, and "ext" instead of "zend_ext" but the html page doesn't provide me anymore informations.
Moreover the weird thing is that when I copy-paste a php -i result in the textarea from https://xdebug.org/wizard, it tells me that xdebug isn't installed .....
I checked and tried many posts' solutions from stackoverflow, but nothing is working, I don't know what to do more, so if any of you guys could help me it would be highly appreciated.
Thank you
Edit: Thank you Arsen for the answer, I tried both of your suggestions and followed the upgrade guide but none is working . Here is my php.ini file which I modified that much that I can't even get back to the base configuration..
Should uninstall wamp and install it again ?
I have a 5.6.40 php version and the preinstalled xdebug 2.5 version is working in netbeans.
The problem is that I will have to modify an app written with php 7 and use phpUnit / phpDocumentor / codeSniffer. Do you think that working with e 5.6.40 php version would be fine ?
Again, I am new to php / wamp and all the related stuff, sorry if my questions are "stupid".
XDebug 3 is still pretty new and it appears your xdebug-configuration in your ini-file is still using the config names for XDebug 2. Luckily, XDebug provides a upgrade guide, which you should adjust your config according to.
My first guess is that you are using the wrong port, because XDebug 3 is using port 9003 by default and you are expecting port 9000 in NetBeans.
So you can either:
Listen on port 9003 in NetBeans or
Set xdebug.client_port to 9000 in your ini-file. (Rather than xdebug.remote_port, see the upgrade guide Ilinked above)
Keep in mind that you should go through the upgrade guide for all your configuration settings to ensure that XDebug is actually doing what you want it to.

How to debug PHP Web Application using Aptana

This feels like a really stupid question, but I cannot find any YouTube videos / articles / guides / etc that explain the debugging process in Aptana.
I've found the ones that explain how to install the XDEBUG or ZEND components, and that's all good. Now, how do I use them? I can see all sorts of menus, server configurations, debug configurations, but I cannot find a guide that explains how to actually set about using them.
Is there some sort of "PHP debugging with Aptana for dummies" that would provide a very direct walkthrough, something along the lines of:
This guide starts by assuming you have installed XDEBUG into your Aptana studio, and confirmed it with phpinfo().
Setup a debug configuration by....
Start your debugger by ....
Step through the code by ....
and so on.
It sounds so obvious, but I cannot even find something like that for a different IDE.
Please someone put me out of my misery.
Hope this helps someone... heaven alone knows why I've battled so much with it.
I am using Aptana Studio 3, build 3.4.2.....
And XAMPP ver 1.8.1 installed on C:\xampp (on a windows machine)
1. Ensure that XDEBUG is PROPERLY installed.
I moved to a new computer, and forgot to check. :(
Open php.ini file under \php directory
Make sure the following lines are uncommented (no semicolon)
zend_extension="<Xampp_Home>\php\ext\php_xdebug.dll"
xdebug.remote_host=localhost (change 'localhost' to '127.0.0.1')
xdebug.remote_enable=0 (change '0' to '1')
xdebug.remote_handler="dbgp"
xdebug.remote_port=9000
Save and restart web server.
2. Setup your web server in Aptana under Window > Preferences > Aptana Web Studio > Web Servers.
(I use virtual host containers.)
Name: MyWebServer
URL: http://MyProject
DocumentRoot: c:\xamppProjects\MyProject\php
3. Setup the PHP interpreter in Aptana under Window > Preferences >
Aptana Web Studio > Editors > PHP > PHP Interpreters.
Add...
Name: XAMPP PHP Debugging
Executable path: C:\xampp\php\php.exe
PHP ini file: C:\xampp\php\php.ini
PHP Debugger: XDebug
Now try it out
In Aptana Studio, select the Debug perspective.
Open a browser and fire up your app (http://MyProject)
Aptana interrupts with a pop window titled "Incoming JIT debug request" and asks "A remote debug request was received from 'MyProject'. Would you like to break on the first line?"
Select yes, and you're into the debugging.
Once I got to this point, I found the setting of breakpoints and tracing the flow pretty painless.

PhpStorm debugger not stopping at BreakPoints; keeps waiting for xdebug _SESSION_

Updated question : PhpStorm | WebMatrix (IISExpress) | Xdebug.remote_port | — Which Port(s) to put where?
I'm running localhost web server on my Windows machine with WebMatrix and IISExpress. I've installed PHP and Xdebug in it and they both are working.
I have a local WordPress install.
I'm now trying to get PhpStorm to debug it using Xdebug.
When I run PhpStorm it launches the web app in the browser with relevant debugging parameters in the browser.
IDE KEY is matching
xdebug.remote_port is configured correctly. (Later I found that this is wrong, but not erroneous. It should be port 9000)
But it seems Xdebug never gets to communicate with PhpStorm. PhpStorm keeps listening, and the execution runs completely without stopping at any break-points.
These lines are crucial to make it work (in php.ini):
zend_extension=/usr/lib/php/extensions/no-debug-non-zts-20121212/xdebug.so
xdebug.remote_autostart = 1 # <-------- THIS
xdebug.remote_enable = 1 # <----------- AND THIS
Without these lines xdebug will never work on phpstorm ;)
Try changing the xdebug listen port in your php.ini and your IDE.
Running Mac Yosemite, for me the problem was that I installed with homebrew, following a guide that used php-fpm, which uses port 9000 by default (which conflicts with the xdebug default port)... Changing my xdebug.remote_port to 9001 and changing the xdebug port in phpstorm fixed the problem, though I suspect this issue could happen for anyone in any IDE. I googled for the better part of a day and didn't see this solution (since I believe it's so specific to install method).. but I hope it helps someone.
Took me about an hour until I noticed that this button wasn't activated ;)
"Run" -> "Start Listening for PHP Debug Connections"
First check for on what port xdebug is working on, you can find it in your php.ini under xdebug.remote_port=9123. As you can see in my case it is set to 9123.
Now open PhpStorm go to php debug, see screenshot:
under Xdebug you will find Debug port, make sure that its value is the same as in the php.ini file under xdebug.remote_port (9123 in my case).
Hope it helps
Could be a Firewall.
Day 572... Still haven't slept or eaten... But I finally found the culprit: Windows Defender!
Basically, I had a firewall blocking JetBrains IDE Support chrome extension from sending data to PhpStorm through the default 127.0.0.1:63342 address.
--- Edit
Day 864... Same issue happened again, this time on Linux... But I finally found the culprit: Ubuntu Firewall!
Seriously, this happened to me again a few months later, using Linux, and it was the firewall again. Disabling the firewall solved it sudo ufw disable - If you care for the firewall and want to keep it enabled, gotta dive in deep on creating some sort of whitelist for it.
For me it was changing the line:
xdebug.remote_host=localhost
to
xdebug.remote_host=myComputerIP
( Mac user: in terminal run ifconfig to find your ip )
If anyone else runs into this issue and is using Vagrant, this is what finally fixed it for me:
xdebug.remote_host=10.0.2.2
That needs to be the IP address of your local machine from inside the Vagrant box, and 10.0.2.2 is the default. If you ssh into your Vagrant box, it will show the IP where you logged in from if you want to confirm.
I know this isn't directly relevant to the specific setup the OP had, but this post shows up in a lot of xdebug / PhpStorm Google searches so hopefully this can help someone else.
PHPStorm has a build-in tool in Run > Web Server Debug Validation.
It helped me to solve my problem.
There was a syntax error in php.ini. There were extra "quotes" and ;colons;.
I also obtain this error message.
Also was troubles with the php.ini but more subtle.
Try to find and delete a row like this
extension=php_xdebug-...
Consider to look at my answer here for details "Xdebug - command is not available".
I was having this same problem while trying to test a Laravel project using XAMPP on Windows in PHPStorm. I have no idea what exactly I was doing wrong, but I did get it working eventually. I followed the step-by-step instructions on the PHPStorm site here.
One thing I think that was not configured right was that there was no interpreter set up in the PHP menu in Settings.
I was also trying a few too many combinations of settings in my php.ini. These were the settings that I have when things were working:
zend_extension = C:\xampp\php\ext\php_xdebug-2.3.2-5.6-vc11.dll //as recommended from the Xdebug site itself
xdebug.remote_enable=1=
xdebug.profiler_enable=1
xdebug.profiler_output_name = "cachegrind.out.%t-%s"
In my Run/Debug Configurations, I use a PHP Web Application setting, that just starts on the root of the site. (At first, I thought the appended ?XDEBUG_SESSION_START=<xxxxxxx> was a mistake, but it is not). Hopefully that might help if someone else is facing a similar issue.
Right click "Console" tab and uncheck "Focus on startup" (as seen in below image) should do the trick
I had an issue where one project would work and not another one. I tried many different configurations and I tried looking at the logs of xdebug, etc. This fix seems to have resolved my issue:
Try setting your actual ports of xdebug to 9123 instead 9000.
The new version (9) of PHPStorm changed its default xdebug connetion port to 9123 (the PHPSTORM config, not the actual xdebug config), probably for a good reason, since having the PHPSTORM config to the xdebug default 9000 didn't work but having them set to 9123 did work and resolved the issue.
I tried any of the suggested tricks and finally I called the script by 127.0.0.1/script.php instead of localhost/script.php and bingo!
Based on peteclark3 answer:
I think one of solutions if you have multiple php-fpm versions with xdebug, like php5.6-fpm, php7.1-fpm - make sure only one is running. I had both 5.6 and 7.1 running. Then tried to change on 7.1 to 9001 port. But if I change to 9001 port in PhpStorm, then 5.6 starts not working, because it listens on 9000. So each time you change php version, then probably you would need to change setting in phpStorm. So I think it is better to have only one of php-fpm running and all php-fpm versions can use same port.
This fix is specifically xdebug working but breakpoints not working with docker
Step 1 (check if xdebug actually works):
Go to settings in phpstorm and then debug, check the box 'break at first line...'
Try again, if it breaks at first script xdebug is working
Could be the breakpoints aren't working because it can't find the file.
Step 2 (check your paths mappings are set up correctly):
Go to servers (it's below debug)
Make sure you have a server set up and 'use path mappings' selected
Below that ensure that your php files are mapped to the correct path in the docker container. In my case files were mapped to /var/www/files but actually in the container it was /var/www/app/files.

Can't get XDebug to make a connection in Vim. Getting "no attribue 'stop'" error

Judging by how many search engine hits this error message generates, I know this is a common problem, yet there aren't any helpful answers out there.
I'm trying to setup XDebug in Vim using Sam Ghods Debugger.vim script while following the instructions on How to Debug PHP with Vim and XDebug on Linux (which is a commonly referenced source on getting Vim setup with XDebug). I'm running MacVim 7.3 on OSX 10.6 and when I try to connect the debugger to the server, I get:
(<type 'exceptions.AttributeError'>, AttributeError("DbgProtocol instance has no attribute 'stop'",), <traceback object at 0x104595680>)
File "/Users/tjlahr/.vim/plugin/debugger.py", line 1078, in debugger_run
debugger.run()
File "/Users/tjlahr/.vim/plugin/debugger.py", line 928, in run
self.protocol.accept()
File "/Users/tjlahr/.vim/plugin/debugger.py", line 560, in accept
self.stop()
Does anybody have experience troubleshooting this error?
Please note that I'm not debugging over port 9000 because it seems it might conflict with fastcgi enabled in PHP. So I'm debugging over port 9001 and have changed by settings in php.ini and the g:debuggerPort variable respectively.
Thanks for your help.
I think I got it!
Can you try installing this Vim Plugin:
http://www.vim.org/scripts/script.php?script_id=2508
It seems that "AttributeError("DbgProtocol instance has no attribute 'stop'",)" is a general error.
I just installed XDebug and the debugger.vim plugin and ended up receiving this message. My problem was that remote debugging was not enabled. Build a phpinfo file:
<?php
phpinfo();
?>
somewhere in your web server directory, and check over all your xdebug configuration variables, which should be listed near the bottom of the page. On my system with xdebug-v2.2.0-dev built from the GitHub repo, xdebug.remote_enable was set to false. Pasting that at the bottom of your php.ini file and setting it's value to 1 enabled clients to connect to the xdebug session.
Also, in the xdebug source there is a directory called "debugclient", which can be used to test any connection problems. Follow the instructions in the INSTALL file in it's directory to build it.
And, one last thought, after you run the plugin script in VIM, you need to refresh the webpage you are trying to debug within 5 seconds, or else the script, acting as a client, will timeout.

Categories