PHPUnit not recognizing cURL extension — can't install selenium test

泄露秘密 提交于 2019-12-21 20:23:46

问题


I'm on a Windows 7 machine running a WAMPserver and I'm trying to install the Selenium extension for PEAR. However, whenever I try to install it, I'm told that it requires the already-enabled PHP extension "curl":

pear install phpunit/PHPUnit_Selenium

Package "pear.phpunit.de/PHPUnit_Selenium" dependency "pear.phpunit.de/PHPUnit" has no releases
phpunit/PHPUnit_Selenium requires PHP extension "curl"
No valid packages found
install failed

So I go to check my php.ini file to see if it's enabled. Sure enough, there it is:

extension=php_apc.dll
;extension=php_bz2.dll
extension=php_curl.dll
;extension=php_dba.dll
;extension=php_exif.dll

On this website, I was told to try this:

  1. If you are getting an error as “No valid packages found Install failed” then run the following command pear upgrade-all

But when I run that command, it just tells me Nothing to upgrade-all.

After searching for my specific error, I found a PHP bug that mentions

The "curl" php extension needs to be loaded into php itself as an extension.

run this command

php -me

If "curl" is not listed as one of the [PHP Modules] it is not going to work.

And I'm not entirely sure how to load this "into php itself as an extension" on Windows. Is there an easy way to do this? Or to get PEAR to believe that I do have this installed?

EDIT

For the record, my curl extension is noticed by PHP (from php_info()):

cURL support    enabled
cURL Information    7.20.0

回答1:


In most cases I'd say that this comes from a php configuration issue.

The easiest way to check for this is to use php -i and see if the curl extension shows up in the output. If it doesn't there is something wrong with the command line php. Chances are it's using the wrong php.ini file. php --ini can be used to check this


But there might be a case where one doesn't want to or can't enable the curl extension for some reason so I'll take that as an answer:

If you don't need the selenium module for phpunit there is a way of skipping the install of this package as it is an optional dependency.

pear install --onlyreqdeps phpunit/phpunit 

should not install Selenium.

And just in case there is always one thing to try:

pear install --force --alldeps phpunit/phpunit

To tell pear to note care about the curl extension not being recognised there is:

pear install --force phpunit/PHPUnit_Selenium

which might work if there is some issue that just pear is not picking the extension up but normal scripts are.




回答2:


I had this problem on Ubuntu, and I solved it by running the following command,

sudo apt-get install php5-curl

Apparently there are two different curl packages (curl and php5-curl), the php5-curl one is for php.

Hope this could help




回答3:


There needs to be changes made to two php.ini in different locations, for example:

  1. C:\wamp\bin\php\php5.3.8
  2. C:\wamp\bin\apache\Apache2.2.21\bin

Starting about line 950 you will see

; Windows Extensions
; Note that ODBC support is built in, so no dll is needed for it.
; Note that many DLL files are located in the extensions/ (PHP 4) ext/ (PHP 5)
; extension folders as well as the separate PECL DLL download (PHP 5).
; Be sure to appropriately set the extension_dir directive.
; 
;extension=php_bz2.dll
;extension=php_curl.dll
;extension=php_dba.dll
;extension=php_exif.dll
...

Change the ";extension=php_curl.dll" to "extension=php_curl.dll"

Restart your server and you should be ready to go.




回答4:


While working on WAMP there are two php.ini files

  1. Under Apache
  2. Under Php

Make sure you have uncommented "extension=php_curl.dll" in both files. You're good after editing both files and restarting your wamp server. The pear installer might be looking for the curl settings in the PHP path even though your wamp server is using the Apache version.




回答5:


when you change php.ini from wamp server even from php menu, it changes the apache version and it dose not effect the php at all. I changed them from file system and it works. :-)




回答6:


I followed these answer above and I changed these files and is working correctly.

C:\wamp\bin\php\php5.3.13
C:\wamp\bin\apache\apache2.2.22\bin


来源:https://stackoverflow.com/questions/8495839/phpunit-not-recognizing-curl-extension-cant-install-selenium-test

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!