phpunit ignores /etc/php5/cli/conf.d directory on startup when launched from within eclipse [duplicate]

StackOverflow https://stackoverflow.com/questions/12603887

  •  04-07-2021
  •  | 
  •  

Question

Possible Duplicate:
While I am debugging PHP Script in Eclipse, it doesn’t load mysql extension

How can I make phpunit scan the /etc/php5/cli/conf.d directory for ini files?

I am using phpunit, but it is very time-consuming to configure correctly. One issue I just encountered is that ini files for my php extensions do not seem to get loaded properly, when I Lauch phpunit as a "Run Configuration" from within Eclipse. I basically followed this tutorial: http://pkp.sfu.ca/wiki/index.php/Configure_Eclipse_for_PHPUnit

When run from within eclipse (Menu Run.../Run Configurations...), then the directory

/etc/php5/cli/conf.d 

which is linked to

/etc/php5/conf.d/

is not parsed. Thus, for example, file

/etc/php5/conf.d/curl.ini 

is ignored. I have to add the one-liner to the ini file

 echo "extension=curl.so" >> /etc/php5/cli/php.ini

which seems to solve the problem, but it is counterproductive, because it breaks modularization (and will be gone after the next distri / php upgrade)

To find this issue, I modified phpunit.php by adding a call to phpinfo() to the beginning of the file.

Here's the output.

PHP Version => 5.3.10-1ubuntu3.4

System => Linux wb3 3.2.0-31-generic #50-Ubuntu SMP Fri Sep 7 16:16:45 UTC 2012 x86_64
Build Date => Sep 12 2012 18:58:31
Server API => Command Line Interface
Virtual Directory Support => disabled
Configuration File (php.ini) Path => /etc/php5/cli
Loaded Configuration File => /tmp/zend_debug/session6700026373526677062.tmp/php.ini
Scan this dir for additional .ini files => (none)
Additional .ini files parsed => (none)

When I inspect /tmp/zend_debug/session6700026373526677062.tmp/php.ini:

using grep -C 2 extension

I got no output.

After adding extension=curl.so to /etc/php5/cli/php.ini the curl extension is loaded when I run the phpunit Eclipse-Run-configuration

But the result is different when I run phpunit from the command line. Now I get

phpunit --debug --verbose  MyClass 
PHP Warning:  Module 'curl' already loaded in Unknown on line 0

Update: (no answers yet)

I found a workaround for my problem:

I created a custom php.ini file in the filesystem, that contains all includes appended, and within Eclipse Preferences for PHP, I create a new configuration for the php5 interpreter, using my special-purpose php.ini.

Within Eclipse Run-Configuration Menu, , setting the Config Dialog Box, I simply point to the new php5-configuration.

But this does not solve the problem, so I'm still looking for answers. Is it an eclipse problem or a phpunit - problem? I have no clue at this time.

Was it helpful?

Solution

This is an expected behavior of Eclipse PDT. For more information, see the similar question and my answer.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top