CRUDlex: Identifier "twig.loader.filesystem" does not contain an object definition.

Hi! Fresh install with Silex-Skeleton, composer edited to require Doctrine DBAL and CRUDlex (which implies more recent versions of twig-bridge and translation):

"require": {
        "php": ">=5.5.9",
        "silex/silex": "~2.0",
        "silex/web-profiler": "~2.0",
        "symfony/asset": "~2.8|3.0.*",
        "symfony/browser-kit": "~2.8|3.0.*",
        "symfony/class-loader": "~2.8|3.0.*",
        "symfony/config": "~2.8|3.0.*",
        "symfony/console": "~2.8|3.0.*",
        "symfony/css-selector": "~2.8|3.0.*",
        "symfony/debug": "~2.8|3.0.*",
        "symfony/finder": "~2.8|3.0.*",
        "symfony/form": "~2.8|3.0.*",
        "symfony/monolog-bridge": "~2.8|3.0.*",
        "symfony/process": "~2.8|3.0.*",
        "symfony/security": "~2.8|3.0.*",
        "symfony/translation": "3.1.*",
        "symfony/twig-bridge": "~3.1",
        "symfony/validator": "~2.8|3.0.*",
        "doctrine/dbal": "~2.2"
    },

Doctrine and Web Profiler working fine.

Adding CRUDlex:

        "philiplb/crudlex": "0.10.x-dev"

Instanciating the MySQLDataFactory, ServiceProvider: OK

Mounting the ControllerProvider results in this error:

InvalidArgumentException in Container.php line 233:
Identifier "twig.loader.filesystem" does not contain an object definition.

I’ve tried to tweak the Twig instanciation, with no result. However when I comment the Web Profiler instanciation:

$app->register(new WebProfilerServiceProvider(), array(
    'profiler.cache_dir' => __DIR__.'/../var/cache/profiler',
));

Then the error disappears and I can use CRUDlex.

So, it looks like issue #41 is back with the latest version.

Any idea?

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 16 (7 by maintainers)

Most upvoted comments

@philiplb you need to extend twig.loader.filesystem like this:

// Silex 1.3
$app['twig.loader.filesystem'] = $app->share($app->extend('twig.loader.filesystem', function($twigLoader, $app) {
    $twigLoader->addPath(__DIR__.'/../templates', 'app');

    return $twigLoader;
}));

// Silex 2.0
$app->extend('twig.loader.filesystem', function($twigLoader, $app) {
    $twigLoader->addPath(__DIR__.'/../templates', 'app');

    return $twigLoader;
});

because $app['twig.loader.filesystem']->addPath() initializes the service and somehow it’s not available anymore in Pimple container (for extending, which WebProfilerServiceProvider is trying to do).