voryx/restgeneratorbundle
Voryx RESTGeneratorBundle is a Symfony bundle that automatically generates RESTful CRUD controllers and routes from your Doctrine entities, letting you expose full JSON APIs with minimal boilerplate and consistent, configurable endpoints.
What you're adopting. VoryxRestGeneratorBundle is a Symfony 2 code generator, not a runtime REST framework. It scaffolds a Doctrine-entity CRUD controller in the style of SensioGeneratorBundle, producing the five standard REST actions (list, show, create, update, delete) plus route/annotation boilerplate. The day-to-day value is skipping repetitive controller wiring — not getting serialization, pagination, auth, or API semantics for free.
Prerequisites.
app/console, app/AppKernel.php).@View/format handling) and JMS Serializer. Check the generated code and add them if those annotations appear.Install and register.
composer require voryx/restgeneratorbundle
// app/AppKernel.php
new Voryx\RESTGeneratorBundle\VoryxRestGeneratorBundle(),
Make sure annotation routing is enabled for your controller directory (routing.yml with type: annotation), or register the generated route resource explicitly.
Where to look first.
app/console list to confirm the command name and options (it will be under the bundle's namespace).Controller/ directory for any base REST controller worth extending.First use case. Pick one small entity (e.g. Post), run the generator, commit the output on a branch, and hit /posts.json (or the prefix you chose). Diff the generated code before customizing so you know exactly what the bundle contributed.
BaseRestController. Centralize pagination, error envelopes, 404 handling, and entity lookup. Keep generated controllers thin so regeneration or copy-paste stays cheap.@Groups, @Exclude) or FOSRest view annotations. Direct entity serialization is the fastest route to circular-reference recursion, N+1 queries, and leaked internal fields.json_decode output blindly.{_format} convention. Preserve defaults={"_format"="json"} from the generator and add a per-resource route prefix. If you convert to YAML routing, keep method names aligned with the generated controller.?page, ?limit, and simple filters in the collection action, backed by Doctrine's Paginator or a paginator bundle.security.yml firewall/access rules per path and HTTP method, plus voters inside the controller for ownership checks.@Route/@Method, and return proper status codes: 201 + Location on create, 204 on delete.EntityUpdater, PaginatorFactory) rather than duplicating generated code.fos_rest format listener and view configuration.@MaxDepth, and join/eager fetching on collection queries..json URLs and with Accept headers. A missing/incorrect _format or Content-Type often yields 406/415 or an empty body. Check whether generated write actions expect JSON bodies or form-encoded data — older generators vary.app/console debug:router after generating.Bundle:Entity repository strings. Multi-EM setups, custom repositories, or non-Doctrine sources require manual edits.debug:router, the profiler's request/response panel, and explicit curl -i calls. Serialization exceptions frequently surface as bare 500s with no body — log them.How can I help you explore Laravel packages today?