在BlueMix上的php环境中使用curl_init()时出错

I use the PHP runtime on Bluemix. In my solution, I need to invoke the external API available on the Internet on port 3000.

I used curl to manage the API invocation using the following code:

$endPoint="http://".$this->server.":".$this->port.$endPoint;
$session = curl_init($endPoint);
curl_setopt($session, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
$data = curl_exec($session);

In the Bluemix log I found the following error:

Got error 'PHP message: PHP Fatal error: Call to undefined function
curl_init() in /home/vcap/app/htdocs/include/service.php on line 50
',
referer: http://m2msite.mybluemix.net/login.php

It does not seem to be a defined curl library inside my runtime.
I do not found any documentation on how to define the curl library in a Bluemix runtime.

Can anyone help me to configure my runtime in a correct way?

Many thanks in advance

I found the solution.

under the project root I create a directory .bp-config
Inside the directory I create a file option.json with the following content:

{
    "PHP_EXTENSIONS": ["mysqli","curl"]
}

mysqli for mysql library and curl for the curl library.

So now I am able to use curl library inside my project

Has anyone the link for a complete documentation around this configuration steps ?

Ciao

the complete documentation for your this kind of configuration related to a PHP buildpack could be found here

https://docs.cloudfoundry.org/buildpacks/php/gsg-php-config.html