$ch = curl_init('http://example.com');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
I want to run curl call, where I am using above code in Lumen but ending up with
Call to undefined function App\Http\Controllers\curl_init() error
Do we have to add any thing in namespace?
I have also tried uncomenting the extension=curl
in php.ini as well as restarted the server
Do we have to add any thing in namespace?
nope.
I have also tried uncomenting the extension=curl
then check your php error log, because the curl extension fails to start for some reason. and since you haven't posted the contents of your error log, nobody here can know why your curl extension fails to load.
(location of the error log is decided by the error_log
php.ini directive, albeit if you're running php behind a webserver like nginx or apache, then the error log is usually just redirected to your webserver's error log. for example with debian/ubuntu nginx+php-fpm, the default error log is nginx's error log at /var/log/nginx/error.log
)