Hi
In my App, the container.config.php
contains:
- Per env specific config (db, webservices, full path to filesystem to save some files, logger config, controllers and middlewares init.
My Controllers are as follow:
- PublicController: all public pages: homePage and password reset request/processing mostly,
- CustomerController: this is the biggest containing all information accessible to logged users protected by Auth middleware: all the processing, and rendering views, and input values checks are done here in seperate methods.
While this is functional, and that db calls or processing is handled in models and service (CustomerService in this case), It’s kinda bloated.
I was instead thinking of:
- Creating 2 base controllers:
- Public Controller
- Customer Controller
Each of those would have separate subControllers per view. Then: 1 view = 1 controller with n actions. For instance for a page showing products:
- ProductController:
Methods: showArticles()
showArticle()
addToBasket()
Is creating controllers this way and adding them to the container.config a good way of doing things?
One advantage it has, is that it’s easy to check for missing or incorrect App settings in one place, the IDE will warn upon instanciation errors and the biggest flaw is that adding controllers involves re modifying the config file in multiple environments.
While this way seem a trivial question, organisation is key to maintainable code.
Care to provide some feedback or large apps?
Bye!