dsw88
dsw88

Reputation: 4592

PHPUnit - Call to undefined function curl_init() error

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?

Upvotes: 3

Views: 4740

Answers (3)

user3350712
user3350712

Reputation: 179

The latest php.ini file will have

;extension=curl

so please remove ; and save works fine

Upvotes: 0

Ader
Ader

Reputation: 1

Open your c:\wamp\bin\php\php5.x.x\php.ini file and find:

    ;extension=php_curl.dll

Just uncomment it by removing the semicolon, such as:

    extension=php_curl.dll

and save the file.

Upvotes: 0

AndrewR
AndrewR

Reputation: 6758

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

You can probably just copy the file C:\wamp\bin\apache\Apache2.2.x\bin\php.ini to c:\wamp\bin\php\php5.3.10\php.ini (adjust for the actual directories on your system).

Upvotes: 9

Related Questions