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.
Related
There is an IIS server with the XDEBUG extension installed, running a PHP application. I can't change nothing on this server. Sometimes, the dev team here needs to debug it, without changing code. Just put some breakpoints and execute it step by step.
I can do it from my computer using Eclipse and remote debugging. But I would like to create a Debian server, in a VM, to make it easy for anyone with just a browser to place breakpoints and step debug that server, without needing to set up an environment.
I tried many Web-Based IDEs (codiad, cloud9, etc), but they don't offer XDEBUG integration. Is there any web-based IDE that I can install in my own server that offers PHP debugging? Please read this paragraph again and don't answer with spam
Or, is there anyway I could run something in the server side such as Sublime Editor, Notepad ++, or whatever, and see it running in a browser? Maybe a Java applet.
Any bright ideas will be very much appreciated! Thanks!
We just released support for debugging PHP with Xdebug inside Cloud9 IDE.
You can place breakpoints (normal or conditional), step over/in/out, set watch expressions, view the call stack, and inspect variables and values. There's also an REPL mode to evaluate code directly.
It's ready to try, but please make sure the correct dependencies are installed on the workspace by running the following commands:
$ npm install -g debug
$ sudo apt-get install php5-xdebug
Set your breakpoints, then click Run > Run With > PHP (cli) to start the debugger and PHP CLI script.
Would love to hear what your feedback is. Our goal is to add support for debugging PHP web pages and Python soon. The implementation is available open-source on GitHub (https://github.com/c9/c9.ide.run.debug.xdebug)
I also made a quick demo video to show you how it works.
I'm founder of Cloud9, so expect extreme bias.
If you are a decent (or better) coder, I have a solution for you. We already have an implementation of XDebug in javascript here: https://github.com/ajaxorg/lib-phpdebug. It might need a bit of updating as it was written for Node 0.6. It does support the latest xdebug.
In addition, we've just released an SDK that allows you to write plugins for Cloud9. Find more info here: http://cloud9-sdk.readme.io/v0.1/docs/getting-started-with-cloud9-plugins. It allows you to install Cloud9 on your own computer or server and you can develop plugins there. You can also distribute your plugin(s) via c9.io and use the SSH workspace feature to have Cloud9 automatically connect to your VM over SSH.
We just released the (pre-alpha) version of the SDK and are actively supporting the handful of developers on the mailinglist here: https://groups.google.com/forum/#!forum/cloud9-sdk.
Implementing a debugger for Cloud9 is actually fairly straightforward. Someone recently built a C++ debugger, which is still in PR here: https://github.com/c9/c9.ide.run.debug/pull/4. You only need to implement one class, the debugger implementation as documented here: https://docs.c9.io/api/#!/api/debugger.implementation. Since there's already an implementation of the xdebug protocol, tying these things together should only be a few days of work.
I hope this helps.
I just downloaded and installed Prestashop, which is a PHP e-commerce system.
I also downloaded and installed XAMPP and Aptana , an open source IDE for PHP development. It uses MVC of some sort. (Sorry, I am completely new to PHP).
It looks ok, I can access the site and the changes I perform in Aptana are reflected in my localhost website.
Now I would like to debug the execution, Aptana has an built-in debugger and it works for a test example I downloaded from the internet (here). It works.
But when I try to set the breakpoint in the Prestashop project, it does not suspend the execution. Also, when I click on a link, the debugger stops.
I really have no idea how to set it up. Do you have any experience in debugging PHP? How can I set it up? I would be fine to change the IDE, if it helped me debugging this system.
Thanks,
Oscar
Prestashop has some good debug code built in already.
In config/config.inc.php change the define for _PS_DEBUG_SQL_ to true (you can also turn error reporting on in here) and in config/defines.inc.php set the define for _PS_MODE_DEV_ to true also.
Use Netbeans to debug your prestashop. In Netbeans you can use Unit Test or etc. check Netbeans tutorial for detail
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/
I am beginner to PHP. I want to debug/execute an existing PHP project. I have already installed Eclipse as IDE and what else should be installed in my system (OS is Windows xp).
And what and all settings should do in that...??
I request you to invest few seconds for this "Kid of PHP".......
I would recommend installing xampp, it allows you to run a website on your local machine.
php and a web server would come in handy ;-)
http://windows.php.net/download/
http://www.apache.org/dyn/closer.cgi
Firephp is a Firefox extension. It works as a module of Firebug. After you install it and add the php library to your code your messages will appear inside the browser. A real quick and clear way to debug in php.
Since you said you are a beginner, it is better NOT to go after advanced debuggers like xDebug at the moment.
print_r(); die;
is the best debugging tool for you now.
Also if you want to nicely format the output of print_r() when arrays or objects are shown, do this:-
echo '<pre>', print_r($array), '</pre>';
And Eclipse! If you are a beginner (or pro), definitely go for NetBeans. NetBeans comes with built-in support for xDebug and zend debugger and a lot other cool stuff you can use when you learn more. If you are going with Eclipse, you will need to install Eclipse extensions like PDT for making Eclipse support PHP.
Of course you will need a web server with PHP support. If you already don't have that, install xampp as somebody mentioned earlier. That's the easy way to get the web server running quickly.
NetBeans is just great, everything works out of the box. Very little to configure. (I'm a former Eclipse user)
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!