PHP in Eclipse not loading Xdebug - php

I'm running Eclipse Mars on OSX, and was using the default PHP 5.5.x in /usr/bin/php. I upgraded to PHP 7.1, installed in /usr/local/php5.
Now, CLI debugging no longer works in Eclipse. When I run phpinfo() as a CLI application from inside Eclipse, it does not show Xdebug being loaded. The Xdebug ini file is in /usr/local/php5/php.d
If I look in the phpinfo() output, I see:
'--with-config-file-scan-dir=/usr/local/php5/php.d'
However it also says:
Configuration File (php.ini) Path => /usr/local/php5/lib
Loaded Configuration File => /private/var/folders/vj/rwjyy7xd08z94cblq7yhnb2w0000gn/T/zend_debug/session6507081221226503822.tmp/php.ini
Scan this dir for additional .ini files => (none)
Additional .ini files parsed => (none)
Which explains why Xdebug isn't being loaded. What is the /private/var/folders... ini file and where is being told to load that from?
Side note: If I run phpinfo() from Eclipse as a web application, it loads Xdebug just fine and debug works just fine.
My question is why isn't PHP within Eclipse scanning /usr/local/php5/php.d and loading those ini files. How do I make it do that?

Found an answer on another thread that works:
PHP not loading xdebug when started from Eclipse PDT
Short answer: for some reason, Eclipse starts php with the "-n" option, which stops loading of ini files. Workaround, found here:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=339547
is to create a script as below that strips the "-n" parameter and runs php. I named it php_eclipse_start. Then set that script as the php executable in Eclipse. This worked. Here's the script:
#!/bin/sh
if [ $1 = "-n" ]; then
shift;
fi
/usr/local/php5/bin/php $*

Related

Strange PHP .ini inclusion in CLI vs Built-in server

My current config:
- MacOS Mojave
- PHP 7.3.5 installed via Homebrew
- XDebug 2.7.2 installed via PECL
- get_loaded_extensions() in both CLI and built-in server is enabled
While trying to configure XDebug on Mac I came across a strange problem.
When calling
$ php --ini
I get
Configuration File (php.ini) Path: /usr/local/etc/php/7.3
Loaded Configuration File: /usr/local/etc/php/7.3/php.ini
Scan for additional .ini files in: /usr/local/etc/php/7.3/conf.d
Additional .ini files parsed: /usr/local/etc/php/7.3/conf.d/ext-opcache.ini,
/usr/local/etc/php/7.3/conf.d/ext-xdebug.ini
whereas calling
print php_ini_scanned_files();
in the script executed via built-in PHP server yields
/usr/local/etc/php/7.3/conf.d/ext-opcache.ini
Web server does not include my xdebug config, therefore there is no way to set xdebug.remote_enable=1 option properly.
What is even "better" is that editing /usr/local/etc/php/7.3/php.ini to cause parsing errors gives no warnings whatsoever.
I'm puzzled. Does anyone has any idea what's the reason behind this?

PHP not loading xdebug when started from Eclipse PDT [duplicate]

I have installed Eclipse and xDebug on Ubuntu 10.10.
When I debug some php file as a page, that works fine.
When I try to debug it as a script, I give the message that mysql extension is not loaded.
I set the following options for PHP executable:
Executable path: /usr/bin/php
PHP ini file: /etc/php5/apache2/php.ini
SAPI type: CLI
PHP debugger: XDebug
I wrote the following script:
test.php
<?php
$ext = get_loaded_extensions();
print_r($ext);
?>
When I put in command line /usr/bin/php test.php
I give 50 loaded modules include mysql and mysqli.
When I debug it as a page in Eclipse I give the same modules and xdebug.
When I debug it as a page in Eclipse I give 45 modules include xdebug, but mysql and mysqli are not loaded.
after struggling with this issue for several hours today, I decided to manually cat all informations inside one single .ini file, and started eclipse with eclipse -clean. something like the following script should do the trick:
#!/bin/bash
mkdir /etc/php5/cli_eclipse
cat /etc/php5/cli/php.ini /etc/php5/conf.d/* > /etc/php5/cli_eclipse/php.ini
(you could obviously check if the dir is already existing etc. but this script is here for illustrative purposes only. you'll need to use a superuser account/sudo to execute this).
point your php runtime in eclipse under window -> preferences -> PHP -> PHP Executables to your created file and restart eclipse once with the -clean flag. pdt should create temporary "php.ini"s containing all necessary information.
The Eclipse PDT team decided to introduce the -n option to fix the Bug #324073. So only php.ini from /tmp/zend_debug/... has been loaded, and all additional INI files have not been loaded.
This has been introduced since PDT 2.2.0 M201010110334 (2010/10/11).
For more information, see the following links:
http://redmine.piece-framework.com/issues/242
https://bugs.eclipse.org/bugs/show_bug.cgi?id=339547
https://bugs.eclipse.org/bugs/show_bug.cgi?id=347618
Try invoke the function described here: http://php.net/manual/en/function.php-ini-loaded-file.php and see if it returns exactly the same path.
On Ubuntu as well as on Debian the php configuration is split among many files. Look at the /etc/php5 (or similar path).
As last resort I would write my own config and reference it in the eclipse php run as script configuration and make sure the config includes and references the mysql extension.

While I am debugging PHP Script in Eclipse, it doesn't load mysql extension

I have installed Eclipse and xDebug on Ubuntu 10.10.
When I debug some php file as a page, that works fine.
When I try to debug it as a script, I give the message that mysql extension is not loaded.
I set the following options for PHP executable:
Executable path: /usr/bin/php
PHP ini file: /etc/php5/apache2/php.ini
SAPI type: CLI
PHP debugger: XDebug
I wrote the following script:
test.php
<?php
$ext = get_loaded_extensions();
print_r($ext);
?>
When I put in command line /usr/bin/php test.php
I give 50 loaded modules include mysql and mysqli.
When I debug it as a page in Eclipse I give the same modules and xdebug.
When I debug it as a page in Eclipse I give 45 modules include xdebug, but mysql and mysqli are not loaded.
after struggling with this issue for several hours today, I decided to manually cat all informations inside one single .ini file, and started eclipse with eclipse -clean. something like the following script should do the trick:
#!/bin/bash
mkdir /etc/php5/cli_eclipse
cat /etc/php5/cli/php.ini /etc/php5/conf.d/* > /etc/php5/cli_eclipse/php.ini
(you could obviously check if the dir is already existing etc. but this script is here for illustrative purposes only. you'll need to use a superuser account/sudo to execute this).
point your php runtime in eclipse under window -> preferences -> PHP -> PHP Executables to your created file and restart eclipse once with the -clean flag. pdt should create temporary "php.ini"s containing all necessary information.
The Eclipse PDT team decided to introduce the -n option to fix the Bug #324073. So only php.ini from /tmp/zend_debug/... has been loaded, and all additional INI files have not been loaded.
This has been introduced since PDT 2.2.0 M201010110334 (2010/10/11).
For more information, see the following links:
http://redmine.piece-framework.com/issues/242
https://bugs.eclipse.org/bugs/show_bug.cgi?id=339547
https://bugs.eclipse.org/bugs/show_bug.cgi?id=347618
Try invoke the function described here: http://php.net/manual/en/function.php-ini-loaded-file.php and see if it returns exactly the same path.
On Ubuntu as well as on Debian the php configuration is split among many files. Look at the /etc/php5 (or similar path).
As last resort I would write my own config and reference it in the eclipse php run as script configuration and make sure the config includes and references the mysql extension.

Eclipse and Xdebug does not parse additional ini files in /etc/php5/conf.d

I have setup Eclipse 3.6.2 on Ubuntu 11.4 for AMD64 and Xdebug.
Eclipse was installed with zip download from eclipse.org.
PHP and Xdebug were setup with apt-get.
When I run the PHP script in the shell they will use the /etc/php5/php.ini file and parse additional ini files in /etc/php5/conf.d/.
When I run in Eclipse (run mode or debug mode) it will only parse php.ini and no additional ini files.
Basically, all extensions, are not loaded.
It is an intentional bug.
PDT executes php with "-n" option always. It makes additional ini files unavailable.
see https://bugs.eclipse.org/bugs/show_bug.cgi?id=339547
also https://bugs.eclipse.org/bugs/show_bug.cgi?id=347618
BTW, you'll be able to add a shell script which trims "-n" option as PHP Executable.(Preferences>PHP>PHP Executables)
For example,
#!/bin/sh
if [ $1 = "-n" ]; then
shift;
fi
/usr/bin/php $*
The answer #atlanto gives as a work around did and does still work, but recent version of Eclipse (I'm on Neon) has a fix that may work for you if you don't mind using the php.ini and conf.d set by default for the php executable.
The failing to load additional files only happens now if you put in an explicit php.ini file when defining a PHP executable. Leave this blank and check the box Use system default php.ini configurate.
Now if you use the location/php.ini that was specified as default when the executable was built, it will respect scanning of conf.d directories.
Here's how to check if your php has scanning conf.d enable and where the approriate default location is:
php -i "(command-line 'phpinfo()')" | grep "Configure Command"
You should see something like:
Configure Command => './configure' '--prefix=/usr/local/Cellar/php5/5.6.29_5'
'--localstatedir=/usr/local/var' '--sysconfdir=/usr/local/etc/php/5.6'
'--with-config-file-path=/usr/local/etc/php/5.6'
'--with-config-file-scan-dir=/usr/local/etc/php/5.6/conf.d'
'--mandir=/usr/local/Cellar/php56/5.6.29_5/share/man'
... and so on...
The items that matter are:
with-config-file-path: this where it will look for your php.ini file
with-config-file-scan-dir: this is the conf.d that will be scanned
If you still wish to choose a different in location than the default for the executable your options are:
Inline the module directives from and file in conf.d into your alternate php.ini
Rebuild php and set the above options to your new location as default
Use the wrapper script #atlanto indicates

PHP Zend Debugger configuration

Hi i am new to php, I currently learning php using eclipse. I know i have to install the zend debugger my php.ini store at c:windows i had added in these line:
[Zend]
zend_extension=c:/php/ext/ZendDebugger.dll
zend_debugger.allow_hosts=127.0.0.1
zend_debugger.expose_remotely=always
zend_debugger.connector_port=10013
but on command prompt i tried php -m it shown that i never install zend debugger. I not sure where goes wrong I check phpinfo also never show any zend information.
I had lots of problems making the debugger work. Now I'm using the ZendServer CE which is free and the configuration is a lot easier.
Also I use Eclipse + PDT, downloaded from Zend Site.
This should work right out of the box. Why not using ZendServer? you get everything you want in a package.
On a browser go to:
http://localhost/?phpinfo=1
look for "Loaded Configuration File"
and take a note of the path
Now open a DOS prompt window (Start > Run > (type) cmd)
and at the command line type
c:\path\to\your\php\php.exe -r phpinfo(); |more
(press CTRL+C to break)
Again look for:
"Loaded Configuration File"
and take a note of this path.
It could be that you are using a different php.ini for your webserver and for the CLI version.
You will need to add the config changes to both php.ini files or put the config in a file called zend.ini and place that in the folder that is mentioned in your phpinfo output under:
"Scan this dir for additional .ini files"
I have experienced the same thing when I was using thread-safe PHP on Windows.
Up to date versions of the Zend Debugger no longer support running in thread-safe flavors of PHP on Windows. Switching to a non-thread-safe (a.k.a nts) flavor of PHP fixed this issue for me.
See here: http://forums.zend.com/viewtopic.php?f=59&t=1918#p13729

Categories