1

I'm trying to make some kind of "reusable" base controller in Symfony 2. Given the name of an entity, is it possible to read the schema of that entity? That is, a list of the entity's fields with the name and the type of each one.

This is in order to automatically generate the inputs in an admin panel and other similar operations.

1

1 Answer 1

1

SensioGeneratorBundle provides CRUD generation capabilities.

Its source code is available on GitHub.
Its documentation is well written; you should probably read it before making your decision.

This bundle can generate a CRUD controller based on a Doctrine entity. Once your application is set up, run the following command:

php app/console generate:doctrine:crud

It will generate forms, controllers and views.
Generated classes are easy to extend.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, it certainly looks interesting, but I'd rather have everything dinamically generated on-the-fly than creating the scaffolding statically, because any change in the model would imply regenerating everything. Currently, in a CodeIgniter implementation I've done, I have an array with the fields names and types, but that's not too elegant xD

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.