App Engine PHP72 标准环境,在本地环境中访问 env_variables
App Engine PHP72 Standard Environment, accessing env_variables in local environment
App Engine 关于 Migrating Your App from PHP 5.5 to PHP 7.2 的官方文档指出:
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.
我的问题是 运行 本地使用 PHP 的网络服务器的应用程序不会自动将存储在 app.yaml
中的 env_variables
添加到 $_SERVER
数组。
下面使用 symfony/yaml
来实现我想要的:
if (php_sapi_name() == 'cli-server') {
$filePath = __DIR__ . '/../app.yaml';
$array = Yaml::parse(file_get_contents($filePath));
$_SERVER = $_SERVER + $array['env_variables'];
}
App Engine 关于 Migrating Your App from PHP 5.5 to PHP 7.2 的官方文档指出:
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.
我的问题是 运行 本地使用 PHP 的网络服务器的应用程序不会自动将存储在 app.yaml
中的 env_variables
添加到 $_SERVER
数组。
下面使用 symfony/yaml
来实现我想要的:
if (php_sapi_name() == 'cli-server') {
$filePath = __DIR__ . '/../app.yaml';
$array = Yaml::parse(file_get_contents($filePath));
$_SERVER = $_SERVER + $array['env_variables'];
}