Migrating Your App from PHP 5.5 to PHP 7.2 上的App Engine官方文档指出:
PHP 7.2运行时不支持dev_appserver.py。去测试 您的应用程序并在本地运行,则必须下载并安装PHP 7.2并设置一个Web服务器。
我的问题是,使用PHP的Web服务器在本地运行应用程序不会自动将存储在env_variables
中的app.yaml
添加到$_SERVER
数组中。
答案 0 :(得分:2)
以下内容使用symfony/yaml
实现了我的追求:
if (php_sapi_name() == 'cli-server') {
$filePath = __DIR__ . '/../app.yaml';
$array = Yaml::parse(file_get_contents($filePath));
$_SERVER = $_SERVER + $array['env_variables'];
}