【问题标题】:App Engine PHP72 Standard Environment, accessing env_variables in local environmentApp Engine PHP72 标准环境,在本地环境中访问 env_variables
【发布时间】:2018-10-31 16:29:27
【问题描述】:

Migrating Your App from PHP 5.5 to PHP 7.2 上的 App Engine 官方文档指出:

PHP 7.2 运行时不支持 dev_appserver.py。去测试 您的应用程序并在本地运行,您必须下载并安装 PHP 7.2 并设置一个网络服务器。

我的问题是使用 PHP 的 Web 服务器在本地运行应用程序不会自动将存储在 app.yaml 中的 env_variables 添加到 $_SERVER 数组中。

【问题讨论】:

    标签: php google-app-engine php-7.2


    【解决方案1】:

    以下使用symfony/yaml 来实现我所追求的:

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

    【讨论】:

      猜你喜欢
      • 2017-09-22
      • 1970-01-01
      • 2018-03-12
      • 2018-07-01
      • 2019-01-30
      • 2015-11-15
      • 2020-11-23
      • 2019-01-16
      • 1970-01-01
      相关资源
      最近更新 更多