0

I'm trying to port a PHP-based API over from shared hosting to Google App Engine. I've downloaded the PHP SDK, created a new application in the launcher, enabled cURL in php.ini (using extension=curl.so), and now I'm getting this error:

Fatal error: Call to undefined function MyNamespace\curl_init() in C:\Users\David\Desktop\GAE\mysampleapp\classes\myclass.php on line 56

If I add a backslash to curl_init() (to tell it not to use MyNamespace), I get this:

Fatal error: Call to undefined function curl_init() in C:\Users\David\Desktop\GAE\mysampleapp\classes\myclass.php on line 56

Short of enabling cURL_lite() (which I might tackle later, because that doesn't support the cURL options i need), how can i resolve this?

EDIT: My question differs from the suggested duplicate, because I'm following Google's own instructions for enabling cURL

EDIT 2: I was able to get this running on the app engine SDK / launcher by changing the extension to php_curl.dll.

Grayda
  • 1,870
  • 2
  • 25
  • 43
  • 1
    Possible duplicate of [curl\_init() function not working](http://stackoverflow.com/questions/4477535/curl-init-function-not-working) – GiamPy Jul 04 '16 at 09:36
  • @GiamPy This is different, because cURL is enabled in php.ini, using the [instructions on Google's own documentation site](https://cloud.google.com/appengine/docs/php/config/php_ini) – Grayda Jul 04 '16 at 13:05
  • Okay, so looks like cURL wasn't actually enabled. See my answer for clarification. Basically I had to remove the quotes on the GAE version, and change to php_curl.dll when doing it locally. – Grayda Jul 04 '16 at 13:28

1 Answers1

0

So GiamPy's comment got me thinking, so I enabled phpinfo() in php.ini and found that cURL wasn't being loaded at all.

I changed the extension to php_curl.dll and it now works. A rookie mistake (I've been writing PHP apps for 10+ years), but this answer didn't fix cURL on the actual App Engine, until I saw an answer in another question, stating that removing the quotes in the extension line worked for them.

So now my local php.ini is:

extension="php_curl.dll"

While my GAE php.ini is:

extension=curl.so

And now I can use both.

Grayda
  • 1,870
  • 2
  • 25
  • 43