How to structure controllers in Symfony2?

Hi!

Today is my second day with Symfony2 and I’m still reading docs.

What’s the best way to structure my controllers? Do I need to create a new controller called UserController.php for users, FeedController.php for feed and CommentController.php for comments or is it okay to put everything in DefaultController.php?

Thanks.

Typically all the CRUD actions of an entity are grouped together. So the actions to create, retrieve, update and delete a user would be grouped into a UsersController. The actions to create, retrieve, update and delete a comment would be grouped into a CommentsController. And so forth.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.