Can Eclipse step into and/or set breakpoints in a PHAR? - php

I would like to step through some third-party code that is in a PHAR. I created the following script in order to attach the debugger.
include('third-party\some.phar');
The debugger breaks on this line but it will not step into the PHAR. I get the error An internal error occurred during: "Debug Source Lookup". java.lang.NullPointerException. When I resume debugging the script runs as expected.
I tried adding the PHAR to the project's Libraries and this allowed me to navigate the code in the PHAR. However, I still cannot set breakpoints or step into the PHAR.
I'm aware that I can extract the PHAR but it has a Stub so I would rather leave it as is.

Related

Sonarqube analysis not working

I have set up SonarQube server on my local system and run sonar runner. it will run good with .html file but when i am trying to run with php file, it failed and showing error like:
java illegal language exception blame sample.php file.
I installed all plugin as below.
git
java
javascript
web
php
c#
but it is not working.
You get this blame error because you are trying to analyze a set of files on which you have uncommitted changes.
To fix this:
Either you make sure that you a running an analysis on source code that has been freshly checked out from your version control system (and not changed since then-
Or you tell SonarQube to not try to get SCM information
You will find this in the "Administration > Configuration > SCM" settings page: it is called "Disable the SCM Sensor"
One more possibility to end up with this error "java illegal language exception blame file-name file" is that your repository could have been shallow cloned with depth=1.
In my case, we configured our jenkins to do a shallow clone with depth = 1 and this error came up. When I changed the depth = 2 and re ran the jenkins job, sonar:sonar worked fine and results are pushed to the sonar server.
Look at the field "Shallow clone depth" in the attached image.
Hope this helps.

Symfony console outputs "i" and commands do not work in Netbeans

I recently updated my composer.phar file to upgrade all of my dependencies, and after that the , the Symfony2 commands in Netbeans no longer works. When I select Run command, an error message says:
<There is no command available (perhaps error?)>
In the output window, it looks like the comand list is being generated, except for one problem
"/usr/bin/php" "/home/web/Project/app/console" "--ansi" "list" "--xml"
i<?xml version="1.0" encoding="UTF-8"?>
<symfony name="Symfony" version="2.5.0 - app/dev/debug">
<commands>
Notice that the second line begins with "i". I think this is the cause of the problem and am not sure how to get rid of it. When I open up a console window, all of the commands work, but each command has the output begin with an i.
I have an older test project, and the commands still work in that so this error must have happened when I updated composer.
I just realized this is a bigger issue. The i is outputted on all pages so none of the pages appear correctly anymore since it begins with i instead of the tag.
Anyone come across this before or know how to prevent symfony from generating the i?

Xdebug triggered by Code Sniffer in PHPStorm

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" %*

xdebug on OS X partially working (e.g., prints stack trace in terminal but not browser).

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.

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