PHP Eclipse Configuration - php

I want to use Eclipse IDE for PHP. I'm new to Eclipse and also to PHP. I installed Eclipse, PHP and Apache. For Eclipse i installed Zend debugger also. I configured Eclipse and set the paths to PHP exe. But when i try to run small PHP code as a script it shows a error message as bellow.
Error launching 'test'
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.
What shall i do for this. Please tell me how to configure Eclipse.
Thanks.

In Debug Configuration -> Installed PHP -> Add (or Edit)
Make sure that the Debugger is set correctly (in my case it should be Xdebug)

Related

Cannot configure Xdebug with XAMPP and PHP 7.3.0

I have Ubuntu 18.04, XAMPP, PHP 7.3.0 and I tried installing XDEBUG using the XDEBUG wizard after pasting the output of my phpinfo() and added the location of xdebug.so in the php.ini file. But still php -m doesn't show XDEBUG. Can someone please help to figure this out? Let me know if anyone successfully implemented this with PHP 7.3 XAMPP and XDEBUG.
XDebug does fully support debugging for PHP 7.3 and XAMPP. I tested it just now again with the latest version of XDebug (2.7.1), PHP 7.3.0 and XAMPP.
At first, it didn't work for me either (except in my first line of code, but it didn't stop in other lines). It was similar to the problem discussed here which was caused by an old version of IDE. Updating my PhpStorm IDE fixed the problem (This problem and fix was only for PhpStorm IDE).
Therefore, if you are using PhpStorm, follow these steps:
Update your PhpStorm to the latest version. I updated it to 2019.1 version and it works fine.
Wait until indexing is done.
Enable accepting debugging, from the top-right button. Image
PS. You should add more details to your question, such as IDE, IDE version, what you have done already, and your debugging settings.
php -m is a terminal command. Be aware that sometimes CLI PHP will use a different ini file than that of your web server PHP.
So you can check which ini files were loaded with this command:
php -i | grep ini
Check you have XDebug installed by checking phpinfo() in your browser. If it is using a different ini, and you want xdebug available in the CLI, copy the ini settings from this one to the one the terminal told you.
Once you know, check the port in your IDE matches the settings the wizard gave you for your ini. PHPStorm for instance defaults to 9000, but if you use PHP-FPM then it uses 9000, meaning I had to make my debug port 9001 and change it in the IDE too.
Make sure the IDE is listening for incoming connections (PHPStorm has a little telephone type icon which will be either green or red)
Make sure you have set a breakpoint in your code. It's a good idea to try it on the first line. Just click to the left of the line of code next to the line number, and you should get a red spot indicating your breakpoint.
Finally, ensure you are sending the XDebug header with your request! I use a browser extension that allows me to enable/disable at the click of a button. Here's one for Chrome! https://chrome.google.com/webstore/detail/xdebug-helper/eadndfjplgieldjbigjakmdgkmoaaaoc?hl=en

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.

How to launch and debug php using VS Code?

I'm new to VS Code and the php world. My experience is more with heavyweight IDE such as Visual Studio. However, I have a need to setup a php environment on my dev machine and am having some trouble getting it to work properly.
My environment is a Win 10 dev machine. I am using VS Code and php ver 5.5. I have properly installed the xdebug extension and verified it is properly installed. I have also installed the php-debug extension in VS Code.
The challenge I'm having and have been unable to find any useful information through google is launching the php website from within VS Code and then being able to debug it.
A few things I have tried, but haven't worked.
I installed the iis-express extension to VS Code which allows for running any folder through iis express. https://marketplace.visualstudio.com/items?itemName=warren-buckley.iis-express
This works, but the website doesn't display properly. IIS returns an error message saying the site is not properly configured. It's apparently missing a mapping or something along those lines.
I followed this blog. http://blog.denouter.net/2015/05/run-php-from-visual-studio-code.html and am able to run the website using the built in php web server.
Installed webmatrix and let the windows platform installer correctly install and wire up iis express to work with php. The same folder works fine when running from webmatrix.
Installed the php-debug extension to VS Code. https://github.com/felixfbecker/vscode-php-debug
Here is what I think I'm missing. I believe I need to launch the website from within VS Code for the debugging to work. I can't figure out how to "launch" the php website from within VS Code. The php-debug extension from VS Code only supports launch. It doesn't support "attach" mode. I suspect this is why when I run the website outside VS Code, the debugger doesn't work. Let me be clear, the debugger is working when I hit F5, it just doesn't ever stop on any breakpoints.
To summarize: How can I launch and debug my php website from within VS Code? I'm looking for a detailed step by step guide.
Thank you
I am the author of vscode-php-debug. You do not need to "launch the website" from inside VS Code. When you start the "Listen for XDebug" configuration from the debug section, VS Code (or rather, my debug adapter) will listen on port 9000 for XDebug. You need to run a web server like Apache, IIS or nginx locally on your PC and configure it to serve PHP files - this has nothing to do with VS Code. Then simply open a web browser and navigate to localhost and XDebug will connect to the debugger, stopping on breakpoints.
The two necessary settings in php.ini are:
xdebug.mode = debug
xdebug.start_with_request = yes
(Do not forget to add the subtitle [XDebug] before the settings.

XDebug on Eclipse PHP problems

I´m starting working with PHP on Eclipse and I´m having a bad time with XDebugger. This is my first time setting up this enrironment...
I´m running Eclipse 3.8.1 with PHP Development Tools SDK (I have also C++ installed on this Eclipse).
I´ve followed the instruction from the official xdebug site to install XDebug. It seens to be installed fine, as we can see from a phpinfo() call:
Well, once installed, I go to Eclipse, insert my breakpoints on the code, configure the debug configuration and when I call Debug As->PHP Web Application all I get is an empty window on Firefox with the following link:
http://localhost/myproject/index.php?XDEBUG_SESSION_START=ECLIPSE_DBGP&KEY=14380396300041
Absolutely nothing happens neither to Eclipse or on Firefox.
Here is my configuation for debugging:
PS: I haven´t installed anything related to ZEND. Is it necessary ? Here is a error I get when using the Zend Debugger option:
Help appreciated!!! Hope this will be basic learning for solving...
To debug on zend debugger, you need zend debugger installed.
For xdebug remote debugging (browser run) you have to enable dbgp protocol:
https://wiki.eclipse.org/Debugging_using_XDebug#Configuration

Can not make PHP PDT xDebug to stop at breakpoints in Eclipse

By choosing Break at First line, the debugger gets active when entering each file, allowing me to step in and out of the code.
But it is a bit cumbersome having to tab your way through half a million steps to get to the point where it starts to get interesting.
My setup is WIMP Window 7, PHP 5.3
; xDebug config
zend_extension = "C:\Program Files (x86)\PHP\v5.3\ext\php_xdebug-2.2.1-5.3-vc9-nts.dll"
xdebug.remote_autostart=0;
xdebug.remote_enable=On
xdebug.remote_host="localhost"
xdebug.remote_port=9000
xdebug.remote_handler="dbgp"
I have made sure that the path mapping is correct.
But could it be because i'm linking to the PHP files from my Eclipse project?
After downloading Eclipse Juno i'm able to stop at breakpoints.
I have tried everything with Eclipse Indigo.
Version: 3.7.2
Build id: M20120208-0800
Just wont work, either with an internal or external browser.
Time to move on to Juno i guess?
Eclipse has an option to turn off "break at first line". Go to "Windows -> Preferences -> PHP -> Debug" and uncheck "Break at first line" and also to go in "Run > Debug Configurations > PHP Web Application" and unselect "Break at first line" in all the configurations. Then restart Eclipse.
For all those, that are still fighting with this problem, some handy tips.
Check which version (package) of Eclipse you have? It turns out, that Helios package has some bugs and doesn't stops on breakpoints, when you debug your application as Web Application. Debugging works only, if you run it as PHP Script. Which makes it pretty useless for debugging process.
You should consider either reverting to older Galileo Package Eclipse for PHP Developers or installing newest Eclipse Juno (or even newest developer version of Eclipse Kepler), which doesn't have PDT support build in, but you can easily add it to then, using Help > Install New Software.. (point it to http://download.eclipse.org/tools/pdt/updates/release).
These versions are reported to be able to debug as Web Application, respecting breakpoints.
Also, remember, that Xdebug must be run as Zend Extension in order to support breakpoints! In other words remove extension=xdebug.so (on Linux or xdebug.dll on Windows) line from your php.ini and replace it with zend_extension=/full/path/to/xdebug.so (on Linux or zend_extension=X:\full\path\to\xdebug.dll on Windows). Zend extensions requires full path, even if they're put into /php/ext folder, as regular PHP extensions. You'll find more info on this in Xdebug FAQ (look for an answer to "Xdebug is only loaded as PHP extension and not as a Zend Extension" question).
Here is a post describing how to get breakpoints to work with XDebug in Eclipse.
http://programmersjunk.blogspot.com/2013/05/eclipse-and-xdebug.html

Categories