Asked  9 Months ago    Answers:  5   Viewed   83 times

I'm using PHPUnit to try to unit test some PHP files that are part of a web application I'm developing. I've got a WAMP server set up, and have set my php.ini file to have the curl extension installed. I've verified it's installed by checking phpinfo(), and curl does have a config section on the page, indicating it's installed.

When I run my entire web application starting from the index page, this php page I'm trying to test finds the curl_init() function without a problem.

When I run my unit test on the file, however, the it gives me the following error:

PHP Fatal error: Call to undefined function curl_init() in ...

Like I said, the file that calls curl_init() works great when run in the context of the whole application, but can't find it when it's being run alone by my PHPUnit tests. Does anyone know why this is happening? Does PHPUnit not know how to find the PHP extensions installed on my WAMP server?



You need to add the Curl libraries to the command line PHP.ini.

You can probably just copy the file C:wampbinapacheApache2.2.xbinphp.ini to c:wampbinphpphp5.3.10php.ini (adjust for the actual directories on your system).

Wednesday, March 31, 2021
answered 9 Months ago

Visit this and have a file under Fixed curl extensions: after download and replace related file then restart server. In browser navigate to localhost and make sure there is curl extensions showing under Loaded Extensions :

Wednesday, March 31, 2021
answered 9 Months ago

You need to make sure that the newly installed php command is executed, not the default one.

Add the folder where the correct php binary resides as the first item to the $PATH environment variable.

Saturday, May 29, 2021
answered 7 Months ago

Check that your session directory is writable by the webserver process.

The best way to do so is to create your own phpinfo file; in any web accessible folder create a file (you can call it test.php or phpinfo.php or whatever you'd like) with the following content:


Open that file in your browser (http://localhost/test.php or similar) and look for the line session.save_path. That's your session folder; make sure the permissions are suitable and see if that helps.

More information from a similar thread.

Wednesday, June 9, 2021
answered 6 Months ago

I ran into the same issue and found the following solution in the documentation:

To run your functional tests, the WebTestCase class bootstraps the kernel of your application. In most cases, this happens automatically. However, if your kernel is in a non-standard directory, you'll need to modify your phpunit.xml.dist file to set the KERNEL_DIR environment variable to the directory of your kernel:

    <!-- ... -->
        <server name="KERNEL_DIR" value="/path/to/your/app/" />
    <!-- ... -->

So check your phpunit.xml.dist configuration file and try to add the absolute path to your app-directory.

Hope it helps.

Friday, July 30, 2021
Bálint Molnár
answered 5 Months ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :