Search code examples
phpgoogle-app-enginezend-framework2glob

glob() fails to return results on Google App Engine, works locally


I'm building an app on Zend Framework 2 which will eventually be run on Google App Engine. As it stands, the app runs perfectly locally using App Engine's dev_appserver.py command. However, once the app is deployed to App Engine Proper I get a White Screen of Death and the following error in the console:

PHP Fatal error:  Uncaught exception 'Zend\Stdlib\Exception\RuntimeException'
    with message
    'glob('module/{*}/config/autoload/{,*.}{global,local}.php', 1024) failed'

The default ZF2 glob for 'config/autoload/{,*.}{global,local}.php' seems to work fine, as the function returns a result, however glob('module/{*}/config/autoload/{,*.}{global,local}.php', 1024) returns false with no visible error messages caught by Zend\Stdlib\ErrorHandler.

Has anyone else experienced this error? I suspect it's due to the way GAE stores files once deployed to the system, but I haven't used it enough to know either way.

The relevant part of application.config.php is as follows:

'module_listener_options' => [
    'config_glob_paths' => [
        'config/autoload/{,*.}{global,local}.php',
        'module/{*}/config/autoload/{,*.}{global,local}.php',
    ],
],

As mentioned above, it works perfectly when run locally, but fails on the second glob() call when run on GAE itself.


Solution

  • It's a known issue. Star the issue to get updated when it's status changes.

    In the meantime, is it possible for you use opendir/readdir? It has the added bonus of apparently being faster.