symfony / maker-bundle

Symfony Maker Bundle
https://symfony.com/
MIT License
3.35k stars 406 forks source link

make:crud requires framework-extra-bundle #255

Closed ckrack closed 6 years ago

ckrack commented 6 years ago

make:crud generates a controller which uses ParamConverter to load entities.

Steps to reproduce:

composer create-project symfony/skeleton
composer req twig orm maker form validator server symfony/security-csrf

Update .env to have some db connectivity: DATABASE_URL="sqlite:///%kernel.project_dir%/var/app.db"

php bin/console make:entity Foobar // add a name field or something
php bin/console doctrine:schema:create
php bin/console make:crud Foobar
php bin/console server:start

Now open the webserver and browse to the route, probably http://127.0.0.1:8000/foobar/new Add an entity Click on the entity show or edit link, probably http://127.0.0.1:8000/foobar/1

Cannot autowire argument $foobar of "App\Controller\FoobarController::show()": it references class "App\Entity\Foobar" but no such service exists.

Entities are not supposed to be autowired, in this case they should be loaded by ParamConverter.

Fix this by installing the bundle containing the paramconverter: composer require sensio/framework-extra-bundle

Note that I started with symfony/skeletoninstead of symfony/website-skeleton, which includes the framework-extra-bundle. However the dependency should be included in MakeCrud::configureDependencies.

kandiaga commented 1 year ago

Hi, Thanks this worked for me : Fix this by installing the bundle containing the paramconverter: composer require sensio/framework-extra-bundle