The recommended way to organize your controllers in a CakePHP application is to group functions related to one model in a controller, like UsersController, ProjectsController, and so on. So you get urls like /users/edit/1 and /projects/show/1. That works fine, but there is a little issue. If you compare the urls with the natural language, such urls are not that easy to read. We can translate them to: “From the users edit the one with id 1″ or “From the projects show the one with id 1″. But that is not the way we usually speak. We say “Edit user 1″ or “Show project 1″. So it would be nice to have similar urls: /edit/user/1 and /show/project/1.

A possible solution is to group similar actions in a single controller. There would be an EditController with user() and project() functions for editing the respective models, and a ShowController with the same functions for showing the models. With some imagination you will see that this approach is similar to the command pattern.

What do you think about such an approach? Is it just a crazy idea on a hot summer day?