Skip to content

make:crud requires framework-extra-bundle #255

@ckrack

Description

@ckrack

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions