I have an application I'm working on in which I make many AJAX calls to external PHP files. These PHP files get certain parameters, connect to the DB, and perform a task with them.
I just recently started using Netbeans for an IDE and love it thus far. However, whenever I put a breakpoint on one of my external PHP files (the ones I'm making AJAX requests to) and attempt to run the debugger, my breakpoints are never hit. Am I doing something wrong? Or does the Netbeans debugger not stop on the breakpoints of external files you are referencing?
NetBeans need to be configured to use xdebug, before you can strt debugging. For instructions on installing and configuring xdebug see here: http://wiki.netbeans.org/HowToConfigureXDebug
Here is a nice step-by-step tutorial for setting this up. A little less wordy than the netbeans documentation:
http://arturito.net/2011/05/21/local-and-remote-php-debuging-in-netbeans-with-xdebug-on-google-chrome-just-like-in-visual-studio/
Related
I'm trying to run a CLI script in PhpStorm and use the debugger to step through it.
It took some doing, but I now have Xdebug installed and the PhpStorm CLI Interpreters dialog confirms that:
I created a Run/Debug config and when I try to execute/debug it, the script runs all the way through without breaking at my breakpoints and I get this error at the bottom of PhpStorm:
The PhpStorm docs say that xdebug for CLI scripts can configured with an environment variable like this:
export XDEBUG_CONFIG="remote_enable=1 remote_mode=req remote_port=9000 remote_host=127.0.0.1 remote_connect_back=0"
I've confirmed that PhpStorm sees that environment variable:
Here is my Run/Debug config:
I'm at a complete loss here. How the heck can I get this thing to debug a CLI php script? Any help is appreciated.
Gah, I hate it when I spend a couple of hours trying to fix something and discover it's totally unrelated.
The problem was that I'm using short tags and my cli php.ini file had short_open_tag=Off. The code I'm running is normally run in a web context and the php.ini for that web context had short_open_tag=On so the code was working.
This code is an api endpoint and I needed to be able to step through and see what was going on and there's nothing that inherently requires it to run in the web context (except for the input params, but I'm faking those for testing purposes anyway).
So, my debug configuration was fine.
I discovered it by trying to reduce the problem further and further and I just tried running the code directly from a command line (php sync.php) to see that it was at least working and producing the correct output.
It wasn't producing the normal api json output, it was just echoing all of the code in the file. That's what led me down the path to realizing my stupid mistake.
Zend Eclipse for PHP Developers Version: 3.2.0
php5.4.12 (wamp)
I'm using php eclipse xdebug for a few years now - sometime the xdebug doesn't break.
I notice that it happen mostly on ajax calls, and I found that one cause is that the previous debug session didn't end.
But now I'm debugging an ajax call,
I'm using the chrome devtool and I do 'replay XHR' to run the exact same ajax call, and it doesn't break 2 out of every 3 runs.
This is a great waste of time for me and I would appreciate any idea of how to overcome it, including a suggestion for a different (and better debugger)
Note:
upgrading the php is not an option because I must use the same version as the production sev.
I also tried upgrading the eclipse - but it causes to many (other) issues
In eclipse->preferences->PHP->Debug->Installed debuggers
choose Xdegbug, and click configure
check the Use Multisession checkbox
click ok
This will cause xdebug to break even when a session is already running - but it can be a pain when submiting multiple requests.
I've read a lot of xdebug / WAMP / NetBeans won't connect messages, but so far they haven't helped.
I've got a php test project that connects to netbeans-xdebug, and lets me break, step, watch variables, and other good stuff.
I did that to test the environment. The local site I want to develop with is an ActionScript 3.0 site with php handlers. I was hoping I could simply point to the src directory, set my URL to http://localhost/TestInterface.swf, and then hit breakpoints as I did earlier. Unfortunately I'm seeing a seemingly unending "Waiting for Connection (netbeans-xdebug)" message at the bottom of the NetBeans IDE and no breakpoints.
When using IE11, the flash app continues to work while "Waiting for Connection", and no breakpoints are hit. My php test project hits breakpoints.
When using Chrome with the NetBeans connector, same thing for both.
My php code is running directly, the URL ends with test.php. My flash code is running flash, and using POST to execute the php scripts. I feel like I'm not directly connecting to the code as far as xdebug is concerned, but I'm still too new to this architecture to know for sure if that's the case, and if so what to do about it.
If anyone has any insights they could share, I'd appreciate it. When I include flash or actionscript in my search for this, it comes up empty.
Thanks.
I suppose something is mysteriously wrong with my system. However, I stopped using IE and Chrome and switched to Firefox, and it's all working as expected.
Until now, I was debugging my PHP scripts and testcases using vim and the appropiate script with python backing it. However, me and my colleagues need to move forward and vim/gvim is not an option for them.
So I've tried to integrate debugging PHPUnit in Eclipse on my setup as an external tool, which again, works with vim. However, it simply waits for something when I
Launch the new external tool, then
start debugging as a CLI script
Remote debugging is enabled, the environment variable XDEBUG_CONFIG="idekey=ECLIPSE_DBGP_127.0.0.1" is also set.
Any ideas?
Addendum
Running the testsuite works. Debugging a web page works. Debugging a given test doesn't.
Eclipse waits forever for something at 57% when trying to debug a phpunit test. I'd like to provide more information, but it doesn't tell me more either.
I have wrote an article about how to get it done launching phpunit unit tests from eclise pdt not using the external tools launcher but the phpunit.php script itself, look here:
http://elespaciodejaime.wordpress.com/2010/04/19/pruebas-unitarias-en-joomla-con-phpunit-y-soporte-para-debugging/
the explanation is at the end, by the way, it is in spanish.
You find a tutorial and the code of a simple lightweight way of testing Joomla 1.5 and Joomla 3.x component here on Github. You can see what changed between testing under Joomla 1.5 and in Joomla 3.x. The examples are based on the use of PHPUnit + DBUnit installed with Composer and configured and run in Eclipse Luna for PHP Developer (PDT).
you can launch a debug session by going to the php debug perspective and select from the menu run->debug->debug as php web page or debug php script.
If you use zend studio you can debug as a php unit test.
There is also a firefox extension that helps with debugging with xdebug https://addons.mozilla.org/en-US/firefox/addon/3960
Also make sure go to preferences panel and select php->debug->installed debuggers and click on xdebug then click on configure. There should be an option to allow incoming connections. Select that and you can launch remote debug sessions from firefox.
I'm using Zend Studio to do remote debugging of my php scripts on a dev server. It works great for web code, but can I make it work with command line scripts?
I have several helper apps to make my application run. It would be really useful to fire up the remote debugger through command line instead of a web browser so I can test these out.
I assume it's possible, since I think Zend is using xdebug to talk to Eclipse. Apparently, it adds some parameters to the request to wake the Zend code up on a request. I'm guessing I'd need to tap into that?
UPDATE
I ended up using xdebug with protoeditor over X to do my debugging.
I was able to get remote CLI debugging working in Eclipse, using xdebug, though I've not tried it with the zend debugger. I would assume this should work the same with ZSfE, if that's the "Zend Studio" you're using.
Since this is more along the lines of product support, your best bet is probably emailing the support people. We bought Zend Studio at my last job and they were always able to help us in a matter of hours.
Feel free to post the answer though, I am sure there are more people looking for it. :)
There's an option to debug a php script,
run->run as->php script
I believe it also has to be in your project root though. Just for clarification, Zend studio uses their own debugger, while the eclipse pdt project you have the option for Xdebug or Zend's debugger.
Haven't tried, but you can set the QUERY_STRING environment variable to the one that toggles the Zend debugger on.
Per this article.
export QUERY_STRING=start_debug=1&debug_host=<host name or IP of the local machine>&debug_port=<the port that is configured in your ZDE settings>&debug_stop=1
And then run the CLI script.
Remote command-line debugging is possible, I just tried it.
In my case I used Zend Studio + Zend Debugger.
This official article here by the Zend people will help you out, it's what I used. It explains all the parameters that must go into the shell command.
Make sure that you have the php.ini properly set on the remote server, and that it allows your IP address and it will work.
Also, you don't need to export the QUERY_STRING variable.
You can just do:
QUERY_STRING="start_debug=1&debug_host=[127.0.0.1]&no_remote=0&debug_port=10137&debug_stop=0" /path/to/php/binary /your/php/script.php
Running that on an SSH shell will light up your Zend Studio. Sweet!