How to check if curl is enabled or disabled
Just return your existing check from a function.
function _isCurl(){
return function_exists('curl_version');
}
how to test if curl is available in PHP without errors
you could check your installed extionsions
$needed_extensions = array('curl', '... other extionsions to check');
$missing_extensions = array();
foreach ($needed_extensions as $needed_extension) {
if (!extension_loaded($needed_extension)) {
$missing_extensions[] = $needed_extension;
}
}
if (count($missing_extensions) > 0) {
echo 'This software needs the following extensions, please install/enable them: ' . implode(', ', $missing_extensions) . PHP_EOL;
exit(1);
}
'
Check to see if cURL is installed locally?
In the Terminal, type:
$ curl -V
That's a capital V
for the version
Enable cURL in Windows 10
Here is the steps to enable curl on Windows :
...
; Directory in which the loadable extensions (modules) reside.
; http://php.net/extension-dir
; extension_dir = "./"
; On windows:
extension_dir = "C:\PathToMyPhp\ext"
...
extension=php_curl.dll
...
[curl]
; A default value for the CURLOPT_CAINFO option. This is required to be an
; absolute path.
curl.cainfo = C:\PathToMyFile\cacert.pem
1 - Make sure your extension_dir point to the php extension directory.
2 - uncomment or add the extension .dll name .
Here is the right syntax by convention for php extensions : php_nameOfTheExtension.dll
The .dll are placed in the extension directory of php or you must place it here in case of 3rd party download.
3 - cacert.pem is optional and is used for SSL transactions.
Download here : https://curl.haxx.se/docs/caextract.html
4 - Check with phpinfo() if curl is in the list and check the configuration.
5 - In case of error, check the error.log and access.log of Apache
Edit 1 :
6 - I forgot : add the paths of your php directory to the Windows Environment PATH Variable for .dll dependencies.
Question/Response here :
Enable CURL on Windows For PHP5.6.4
Edit 2 :
Here is the path for the files :
Depending on MySQL installation & version
C:\Program Files\MySQL\MySQL Server 8.0\bin\libeay32.dll
C:\Program Files\MySQL\MySQL Server 8.0\bin\ssleay32.dll
Depending on your php directory
C:\php7\libssh2.dll
Edit 3 :
Example of extensions configuration with the right syntax taken from PHP5 but working also for PHP7 :
; 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_fileinfo.dll
;extension=php_ftp.dll
extension=php_gd2.dll
;extension=php_gettext.dll
;extension=php_gmp.dll
extension=php_intl.dll
;extension=php_imap.dll
;extension=php_interbase.dll
;extension=php_ldap.dll
extension=php_mbstring.dll
extension=php_exif.dll ; Must be after mbstring as it depends on it
extension=php_mysqli.dll
;extension=php_oci8_12c.dll ; Use with Oracle Database 12c Instant Client
;extension=php_odbc.dll
extension=php_openssl.dll
;extension=php_pdo_firebird.dll
extension=php_pdo_mysql.dll
;extension=php_pdo_oci.dll
extension=php_pdo_odbc.dll
;extension=php_pdo_pgsql.dll
extension=php_pdo_sqlite.dll
;extension=php_pgsql.dll
;extension=php_shmop.dll
; The MIBS data available in the PHP distribution must be installed.
; See http://www.php.net/manual/en/snmp.installation.php
;extension=php_snmp.dll
;extension=php_soap.dll
extension=php_sockets.dll
extension=php_sqlite3.dll
;extension=php_tidy.dll
;extension=php_xmlrpc.dll
extension=php_xsl.dll
zend_extension="C:\php-7.1.22\ext\php_opcache.dll"
zend_extension="C:\php-7.1.22\ext\php_xdebug-2.6.1-7.1-vc14-x86_64.dll"
Hope this will help.
How to check if curl has support for ssl?
See http://www.php.net/manual/en/function.curl-version.php
$version = curl_version();
$ssl_supported= ($version['features'] & CURL_VERSION_SSL);
In $version['features'] you have a features bitmask. Through an and operation between this bitmask and the proper constant you can check if a feture is enabled.
Possible constants are:
CURL_VERSION_IPV6 (integer)
CURL_VERSION_KERBEROS4 (integer)
CURL_VERSION_SSL (integer)
CURL_VERSION_LIBZ (integer)
CURL is enabled in PHP but disabled in Laravel
I was running Laravel with:
php artisan serve --host 0.0.0.0
but when I changed it to :
php artisan serve --host my_private_IP
it's working now.
PHP: CURL is enabled but has no effect
Your code is perfect, I have tested it on my own server (data center in Texas) and it worked fine.
My guess is that your server IP is banned. Try to fetch a different URL, and see if it works for you. If it does then you are banned, if it doesn't then it might be a firewall configuration issue in your server.
cURL not sure if enabled
You could also do:
<?php
var_dump(curl_version());
?>
if it doesn’t exist you’ll see an error message like this:
Fatal error: Call to undefined function: curl_version()
cURL is enabled in php.ini but still not working
I resolved the issue by editing my PHP.ini
to include the full path of the extension as opposed to just the name.
So where most php.ini
files just have this line of code:
extension=php_curl.dll
I changed it to look like this:
extension=C:\amp\PHP\ext\php_curl.dll
I have no idea why PHP/Apache couldn't show an error while I had extension=php_curl.dll
in my php.ini
. At least saying something like dll missing
or something like that, but that resolved my issue.
Related Topics
Php: Inserting Values from the Form into MySQL
Create a Dynamic MySQL Query Using PHP Variables
How to Concatenate Multiple Ternary Operator in PHP
How to Sum N Number of Time (Hh:Mm Format)
Checking If Array Is Multidimensional or Not
How to Update/Edit a JSON File Using PHP
How to Use Regexiterator in PHP
Passing PHP Variable into JavaScript
Truncate Float Numbers with PHP
Seamless Way to Check If User Likes Page
Install Imagick for PHP and Apache on Windows
How to Fetch All in Assoc Array from a Prepared Statement
PHP Exec $Path Variable Missing Elements
How to Access Route, Post, Get etc. Parameters in Zend Framework 2