How to easily enable/disable Chrome/Eclipse debugger? - php

I am using Google Chrome, Eclipse 2020 to Xdebug PHP on Manjaro Linux. I don't want Eclipse to run the debugger every time I need to check the script. Is there a way (an easy way) to disable Xdebug and re-enable it every time I want? Thank you!

Yes, use one of the browser extensions, as is explained in the Xdebug documentation: http://xdebug.org/docs/step_debug#web-application
You can just toggle whether Xdebug needs to initiate a request or not. The IDE needs to be in "listen mode", although I am not sure whether this is something that Eclipse supports. PhpStorm and the Xdebug plugin for VS Code do.

Related

A couple questions about configuring xdebug for use in PhpStorm IDE

So, I'm trying to configure PhpStorm to debug my application that's running on a Vagrant instance. I have some gaps in my knowledge as far as how this should work:
Q1: The VM's php interpreter and php.ini are being used and PhpStorm lists a version of xdebug next to them as the debugger being used (example: "Debugger:xdebug.(insert version)"). If it didn't think that php was set up to use xdebug, it would have listed "Debugger:none". phpinfo() also shows this same version of xdebug as the one being used. How is this possible when the php.ini file I'm using has no mention of xdebug anywhere? My understanding is that these two mechanisms (phpstorm debugger recognition and phpinfo()) use configuration to figure out what debugger I'm using. Could the xdebug reference be in another .ini file? I'm using php 7.
Q2: When I try and use PhpStorm's "Validate Debugger Configuration on Web Server" service it asks for a "Path to create validation script" and a "Url to validation script". What do these two fields mean and what values should I give them if I want to validate the Vagrant box's Debugger config?
Thanks for any input.

Is it possible to use Eclipse PDT without a debugger?

I'm weaning myself off of PhpStorm for the inevitable day my student license expires. I'm trying to set up PDT (comments regarding other free PHP environment suggestions are appreciated, but do not answer the question).
Anyways, when I add a PHP executable, there is a mandatory option for a debugger. Leaving the default at Zend, when attempting to run a hello world file with the big green button I get a
"Launch Error - Session Terminated"
"Error launching testFile The session could not be started.
In order to generate debug information, please make sure that the debugger is properly configured as a php.ini directive."
The question is basically - is this error generated because I haven't set up a debugger? But it follows, if so, to ask if it is possible to use PDT without a debugger. If it is not possible, why? You don't need a debugger for PhpStorm. Is it simply a matter of Eclipse not supporting this use case, or is there a gap of my understanding of the toolchain and is PhpStorm doing something significant to make itself work without a debugger?
And I guess, is there any reason to actually want to not install a debugger besides (the probably negligible) overhead to actually setting it up?
Of course you can use PDT without a debugger. Due to this bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=462020, you have to configure executable with xdebug.
You can also create official bug on bugs.eclipse.org to add "none" in php cli configuration.
EDIT:
In PDT 3.5 (Eclipse 4.5 - Mars release), we added "NONE" as possible choice. See: https://bugs.eclipse.org/bugs/show_bug.cgi?id=467260

Solution to debug PHP code on remote server, using remote IDE

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.

What to do to dubug/execute an existing PHP project

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)

Remote Debugging PHP Command Line Scripts with Zend?

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!

Categories