php - App Engine PHP72 Standard Environment, accessing env_variables in local environment

232

App Engine's official documentation on Migrating Your App from PHP 5.5 to PHP 7.2 states:

dev_appserver.py is not supported with the PHP 7.2 runtime. To test your application and run it locally, you must download and install PHP 7.2 and set up a web server.

My problem is that running the app locally using PHP's web server does not automatically add theenv_variables stored inapp.yaml to the$_SERVER array.

235

Answer

Solution:

The following usessymfony/yaml to achieve what I'm after:

if (php_sapi_name() == 'cli-server') {
  $filePath = __DIR__ . '/../app.yaml';
  $array = Yaml::parse(file_get_contents($filePath));
  $_SERVER = $_SERVER + $array['env_variables'];
} 

People are also looking for solutions to the problem: php - Wordpress : Fatal error: Uncaught ArgumentCountError: Too few arguments to function posts_custom_columns(), 1 passed in

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.