PHP accuses Curl is not installed

0

I downloaded the .exe from the official website, added the system variable and tested it. Everything working.

But when I go in my PHP program it always gives the same error:

  

Fatal error: Call to undefined function curl_init ()

My code in the snippet that gives the problem:

 <?php
    $url_recepient = "https://api.pagar.me/1/recipients";
    $ch = curl_init();
    curl_setopt( $ch, CURLOPT_URL, $url_recepient);
    curl_setopt ($ch, CURLOPT_POST, 1);
 ?>

And now I do not know if it's my code error or I did not install it right.

    
asked by anonymous 23.08.2016 / 02:52

1 answer

2

This is because the cURL library is not installed and enabled.

To enable on windows:

Create a file named info.php with content:

<?php
phpinfo();

Access the URL of the above-mentioned file and find the path of the specified file php.ini in Loaded Configuration File , then open the entered 'php.ini' file and remove the semicolon from the line:

;extension=php_curl.dll

It should look like this:

extension=php_curl.dll

Save the file php.ini .

Copy the files php_curl.dll , ssleay32.dll and libeay32.dll to your Windows/system32 folder

Restart the web server and run the tests.

To install and enable in linux (Debian / Ubuntu):

sudo apt-get install php5-curl
sudo service apache2 restart

To install and enable in Linux (CentOS):

yum install php-curl
sudo service apache2 restart

If everything went well:

If everything went well, you should find something similar to the image below in your phpinfo(); , stating that the cURL library is installed and informing your settings

IfyouarerunningviaPrompt

Use" -c caminho_do_php.ini "

php -c C:\php\php.ini -S localhost:8080 
    
23.08.2016 / 03:03