Sandrine Berthier
Sandrine Berthier

Reputation: 21

Call to curl_init not found from symfony controller but works just fine from command

I have been trying to use a service calling curl_init in a Symfony projet. The service works just fine when I call it from a Command class of Symfony but fails from any controller.

Here is the function :

public function exist($type, $id)
{
$flux = curl_init();
curl_setopt($flux, CURLOPT_URL, $this->urlelastic.'/'.$type.'/'.$type.'/'.$id);
curl_setopt($flux, CURLOPT_RETURNTRANSFER, true);
$response  = json_decode(curl_exec($flux), true);
curl_close($flux);
return($response["found"]);
}

When called from a command it works just fine. From a controller, I get an 'Attempted to call function "curl_init" from namespace "MyBundle\Service". ' error.

I found multiple thread stating that installation of curl was required : it is installed and works fine.

If anyone has got a clue, I must say that I am a bit perplexed.

Thanks in advance

Upvotes: 0

Views: 320

Answers (1)

Sandrine Berthier
Sandrine Berthier

Reputation: 21

I finally found what was wrong : apache2 was not using the right version of php whereas my cli was => changing the configuration of apache enabled the module and solved the problem.

Thanks all the same.

Upvotes: 1

Related Questions