2

I’ve read the documentation on https://cloud.google.com/appengine/docs/php/symfony-hello-world and I managed to deploy the Hello World app, but when I try with my symfony app I have his error:

InvalidArgumentException in XmlFileLoader.php line 259: Unable to parse file "(…) DependencyInjection/../Resources/config\web.xml".

In app.yaml I set the env variables:

env_variables:

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

And I overloaded the AppKernel.php functions:

public function __construct($environment = null, $debug = null) { // determine the environment / debug configuration based on whether or not this is running // in App Engine's Dev App Server, or in production if (is_null($debug)) { $debug = !Environment::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');
}
}
?>

The functions which write to the file system are redirected to the bucket.

Could you help me to find what modifications are missing in my app.

I hope this topic will help someone else because the Google cloud documentation isn't very up to date.

Thank you in advance and sorry if I don’t speak English very well I’m a French IT student.

Augustin

Jon Winstanley
  • 23,010
  • 22
  • 73
  • 116
  • This is likely not related to GCS since you can still read static files from the filesystem. The app should be trying to load /vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Resources/config/web.xml. To be sure, you should include the full error message in the question instead of a truncated version. Can you compare this file in your app to the one from the working symfony-starter? Did you base your app off the working starter app, or do something differently to try to make it work on App Engine? – Adam Apr 17 '16 at 19:39

1 Answers1

1

I have spent many an hours on this horrible bug, and what I found was this issue happens on the Dev AppServer, but not in production. I believe it is an issue with the implementation of the xml.so php extension in that environment.

This is fixed in the symfony starter app with the method fixXmlFileLoaderBug, which gets called in web/app.php. So ensure this is being called, and you should be good to go.

If you're experiencing this bug in Production, or you continue to experience this issue even after calling this function, please let us know by filing an issue on github.

Brent Shaffer
  • 491
  • 3
  • 11
  • thank you for your answer, but I finally choose to give up with the Google cloud platform and I manage to deploy my app on Amazon. I was stuck in prod with the files limit http://stackoverflow.com/questions/1462208/is-it-correct-that-you-are-allowed-3-000-files-per-app-engine-app-not-1-000 – Augustin Chini Jun 08 '16 at 11:54