philiplb/CRUDlex

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

Closed this issue · 7 comments

Hi,
I wanted to try CRUDlex, installed it, made the params in app.php.

When I add the line $app->mount('/crud', new CRUDlex\ControllerProvider()); is raises the exception

I tried with CRUDlex 0.11 and 0.12, I made my projet up to date and maybe CRUDlex is not compatible with Symfony 3. Here is my composer.json for information

{ "name": "fabpot/silex-skeleton", "description": "A pre-configured skeleton for the Silex microframework", "license": "MIT", "type": "project", "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/security-csrf": "^3.2", "symfony/dom-crawler": "~2.3", "symfony/debug": "~2.8|^3.0", "symfony/filesystem": "~2.3", "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/serializer": "~2.3", "symfony/translation": "~2.8|^3.0", "symfony/twig-bridge": "~2.8|^3.0", "symfony/validator": "~2.8|^3.0", "doctrine/dbal": "~2.2", "swiftmailer/swiftmailer": "5.*", "twig/extensions": "^1.2", "symfony/http-kernel": "^3.3", "philiplb/crudlex": "0.12.x-dev" }, "autoload": { "psr-0": { "": "src/", "MyProject": "src/" } }, "extra": { "branch-alias": { "dev-master": "2.0.x-dev" } } }
Thanks for the help

Hi,
I've just thrown your sample composer.json into a CRUDlexSample, ran composer update and gave it a try. Worked fine for me. Can you show a minimal example index.php where this error occurs?

You mean online? I'm on a local dev environment. But your question about index.php made me switch between index_dev.php and index.php. I noticed that the behaviour in accessing /index_dev.php/crud/book and /index.php/crud/book differs.
I have the error with index_dev.php whereas it works with index.php, though I have a «No entity found» error…

I mean as a gist or maybe even the whole project as zip, so I can reproduce that behaviour locally. Of course, only a minimal application just reproducing this error.

OK, well, yes, I can send you my src and web repos if you want…
I just realized that I had a typo in crud.file parameter, when I set the good filepath, it no longer works with index.php… I'm lost…
Do you want a zip file by mail?

Mail would be good, yes. Please strip it down to a minimum reproducing example so I don't have to dig through a lot of code.

After some searches, I found this issue #63 and this one #41.
So I made some attempts.

It finally works!
I instanciated CRUDlex in a /config/crudlex.php file containing

$dataFactory = new CRUDlex\MySQLDataFactory($app['db']);
$app->register(new CRUDlex\ServiceProvider(), array(
'crud.file' => DIR . '/../path/to/CRUDlex/crud.yml',
'crud.datafactory' => $dataFactory
));
$app->mount('/crud', new CRUDlex\ControllerProvider());`

and placed it like this in my index_dev.php like this

require_once DIR.'/../vendor/autoload.php';
Debug::enable();

$app = require DIR.'/../src/app.php';
require DIR.'/../config/crudlex.php';
require DIR.'/../config/dev.php';
require DIR.'/../config/config.php';
require DIR.'/../src/controllers.php';
$app['twig.loader.filesystem']->addPath(DIR.'/../templates', 'app');

$app->run();

and like this in index.php

ini_set('display_errors', 0);

require_once DIR.'/../vendor/autoload.php';

$app = require DIR.'/../src/app.php';
require DIR.'/../config/crudlex.php';
require DIR.'/../config/prod.php';
require DIR.'/../config/config.php';
require DIR.'/../src/controllers.php';
$app->run();`

Thanks for the help

Very good. :)
Feel free to reopen if you feel something in CRUDlex needs to be adjusted.