I have both xdebug and Code Sniffer working great on my installation of PHPStorm, but the one really annoying part is that the debugger now seems to be treating Code Sniffer errors as breakpoints and interrupts the code to let me know of style warnings while I'm trying to test out code. What can I do to prevent Code Sniffer from being caught by the remote debugger in PHPStorm?
PS: I'm running Apache, using virtual hosts to map certain URLs to folders on my computer, and code sniffer never triggered PHPStorm's remote debugger explicitly, while my site caused PHPStorm to ask me if I wanted to include it's virtual URL for debugging.
I had a similar problem and I solved it like this:
- went to "Project settings" -> "PHP" -> "Debug"
- under "XDebug" I unchecked the two "Force ..." options.
Hope it does the trick for you.
I have added "-dxdebug.remote_enable=0" argument in last line of phpcs.bat and phpcbf.bat.
"%PHPBIN%" -dxdebug.remote_enable=0 "%~dp0\phpcbf" %*
Related
I have properly running xdebug on vagrant on my local pc on Ubuntu. It shows its orange table with error info. My testing page is localhost:8030
In Chrome browser I have Xdebug helper.
The problem is that an annoying warning is displaying in PhpStorm each time I refresh the site:
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 'localhost' server at PHP | Servers or enable Break at
first line in PHP scripts option (from Run menu).
I have checked path mappings configuration for 'localhost' server at "PHP | Servers" and they are OK. My PhpStorm project directory is associated to default Vagrant directory /vagrant/web/.
Enabling Break at first line in PHP scripts option does help but it is kind of an opportunism I think.
How to get rid of these PhpStorm warnings?
For PhpStorm 2021.1.1 +
[Ctrl] + [Alt] + S
Settings : Php -> Debug
Scroll to Advanced settings and expand
Uncheck option Notify if debug session was finished without being paused
It would do this if there are no breakpoints being hit when debugging the script. The "break at first line" probably prevents PhpStorm from issuing you the warning, but otherwise it does exactly the same.
In case you do have breakpoints configured, and PhpStorm doesn't stop on them, then it is likely that you have path mappings configured wrongly.
Using Xdebug's xdebug.remote_log=/tmp/xdebug.log setting/feature to see which breakpoints PhpStorm tries to set, and see whether it does so for the correct paths. They will up as breakpoint_set commands in the log file.
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.
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.
I'm trying to get xdebug working on my Mac. I'm using OS 10.6 with the built-in versions of Apache (2.2.1) and PHP (5.3.8). I followed the "tailored installation instructions" on the xdebug website, which basically consisted of these steps:
Build xdebug (version 2.1.3) from source
Move xdebug.so to /usr/lib/php/extensions/no-debug-non-zts-20090626
Add to php.ini:
zend_extension = /usr/lib/php/extensions/no-debug-non-zts-20090626/xdebug.so
Restart the webserver.
From what I understand, that should be it. I know most people use xdebug with an IDE like PHPEclipse, but it doesn't sound like that's necessary just to get debugging output on the page. And a lot of old instructions involve installing MAMP, but it looks like that's no longer necessary.
Signs xdebug is working: When I run php -m and phpinfo() I get the expected information on xdebug. In scripts I'm able to call functions like xdebug_is_enabled() (returns 1) and xdebug_get_function_stack() (returns the stack).
Ways xdebug is not working: The main reason I installed xdebug was to get a stack trace when there's an error, and that's not happening. According to this documentation page, I should get a stack trace as long as display_errors is set to On in php.ini, (which it is). I've tried code that should evoke a warning (e.g., echo(hello)) as well as code that produces a fatal error (e.g., $x->awesomefunction() when $x isn't an object). Neither one produces any xdebug output, and the fatal error just causes the page to die silently. The test code given in the documentation I linked to also produces nothing.
UPDATE: It turns out that if I run a script with a fatal error from the terminal, I do get a stack trace from xdebug. However, it's still not showing up when I run the script from a browser
Also, regular error reporting is now broken: Previously, I'd get error output by including the commands:
ini_set("display_errors","1");
ERROR_REPORTING(E_ALL);
Now, putting those lines in my script doesn't produce any error reporting either. (in the browser. It does cause errors to be shown when I run the script from the terminal.)
So, what's wrong here? Did I leave something out of the xcode installation? Do I have a setting hanging around somewhere else on my system, suppressing errors? I've tried everything I can think of, but I'd be happy to test any ideas you have.
If it is working on console and not on browser, it's probably a xdebug configuration issue.
I'm not a Mac user, but on Ubuntu there are 2 different php.ini files, one for console and one for apache. If that's the case for Mac also, you can check if xdebug is enabled and properly set up in both php.ini files.
Also you can check the xdebug settings mentioned in the guide.
After several more hours of thrashing, I discovered that one of my test files actually was including another file that set display_errors to 0. The other test file was straight off of the xdebug site, but I think that at the time I was using it I'd introduced some other config error that prevented it from working properly. I'm truly embarrassed! Let this be today's object lesson in the importance of systematic, repeatable tests during debugging. On the bright side, xdebug is now working like a peach.
To summarize, the series of steps that worked was:
Build xdebug (version 2.1.3) from source
Move xdebug.so to /usr/lib/php/extensions/no-debug-non-zts-20090626
Add to php.ini: zend_extension = /usr/lib/php/extensions/no-debug-non-zts-20090626/xdebug.so
Add to php.ini: display_errors = On
Restart the webserver.
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.