简体   繁体   中英

PHP in Eclipse not loading Xdebug

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 $*

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM