将Symfony应用程序部署到谷歌应用程序引擎


Deploying a Symfony App to Google App Engine

我已经阅读了https://cloud.google.com/appengine/docs/php/symfony-hello-world我设法部署了Hello World应用程序,但当我尝试使用我的symfony应用程序时,我遇到了他的错误:

XmlFileLoader.php第259行出现InvalidArgumentException:无法解析文件"(…)DependencyInjection/../Resources/config''web.xml"。

在app.yaml中,我设置了env变量:

env_variables:

GCS_BUCKET_NAME: "pinterpandaibucket"
CACHE_DIR: "gs://pinterpandaibucket/symfony/cache"
LOG_DIR: "gs://pinterpandaibucket/symfony/log"

我重载了AppKernel.php函数:

公共函数__construct($environment=null,$debug=null){//根据是否正在运行来确定环境/调试配置//在应用引擎的开发应用服务器中,或在生产中if(is_null($debug)){$debug=!环境::onAppEngine();}

    if (is_null($environment)) {
        $environment = $debug ? 'dev' : 'prod';
    }
    parent::__construct($environment, $debug);
    // Symfony console requires timezone to be set manually.
    if (!ini_get('date.timezone')) {
      date_default_timezone_set('UTC');
    }
    // Enable optimistic caching for GCS.
    $options = ['gs' => ['enable_optimsitic_cache' => true]];
    stream_context_set_default($options);
    $this->gcsBucketName = getenv('GCS_BUCKET_NAME');

public function getCacheDir()
{
    if ($this->gcsBucketName) {
        return getenv('CACHE_DIR');
    }
    return parent::getCacheDir();
}
public function getLogDir()
{
    if ($this->gcsBucketName) {
        return getenv('LOG_DIR');
    }
    return parent::getLogDir();
}
public function registerContainerConfiguration(LoaderInterface $loader)
{
    $loader->load($this->getRootDir().'/config/config_'.$this->getEnvironment().'.yml');
}
}
?>

写入文件系统的函数被重定向到bucket。

你能帮我找出我的应用程序中缺少哪些修改吗。

我希望这个话题能帮助其他人,因为谷歌云文档不是最新的。

提前谢谢你,如果我英语说得不太好,我很抱歉,我是一名法国IT学生。

Augustin

我花了很多小时研究这个可怕的错误,我发现这个问题发生在Dev AppServer上,但在生产中没有。我认为这是xml.so php扩展在该环境中实现的一个问题。

这在symfony starter应用程序中用方法fixXmlFileLoaderBug修复,该方法在web/app.php中调用。所以,确保这是被调用的,你应该很好地去。

如果您在生产中遇到此错误,或者在调用此函数后仍然遇到此问题,请在github上提交问题,告知我们。