How to enable CURL when using Google Cloud Shell Editor as the local development environment?

1.8k Views Asked by At

I am using Google Cloud Shell Editor as my local development environment and I can't seem to figure out how to enable CURL. I have an app.yaml file and php.ini file in the root directory of the PHP55 project.

The question is: What is the correct way to enable CURL when using Cloud Shell Editor?

First I read that for a "local development environment", use:

extension = "curl.so"

Then I also read that for a "Windows environment", use:

extension = "php_curl.dll"

Finally, I also read that for a "production environment", use:

google_app_engine.enable_curl_lite = "1"

No matter which of these methods I try to enable CURL, I keep getting this same error:

Uncaught Error: Call to undefined function curl_init()

What am I doing wrong? How can I get CURL working in Google Cloud Shell Editor?

1

There are 1 best solutions below

2
John Hanley On

The following steps will generate the following warning:

You are running apt-get inside of Cloud Shell. Note that your Cloud Shell machine is ephemeral and no system-wide change will persist beyond session end.

You will need to repeat the install each time you startup Cloud Shell. There are scripts that can run at Cloud Shell startup to do this for you. link

  1. Do not modify php.ini - return the file back like it was.
  2. Cloud Shell uses this file: /etc/php/7.2/mods-available/curl.ini which will be created for you.
  3. Install curl: sudo apt-get install php7.2-curl