I have a question for which there may not be a definitive/correct answer but I’d figure I’d try my luck to get some insightful opinions:
I have a dependencies.php which initializes things like
- DB Connection (*)
- Session (*)
- Logger (*)
- CSRF (*)
- Mailer (*)
- 500/404 handlers
I also have a bunch of middlewares which set up the following:
- Role based Auth Checking
- Custom class loader
- View/Twig initialization
My problem is that the stuff in dependencies.php is just a long list of raw PHP code (ie: no classes, just a list of PHP commands), while the middlewares are nicely encapsulated classes. It seems to me that just about anything done in dependencies.php (basically the stuff marked with a (*)) could all be moved to middleware which (I think) would result in a nicer architecture since I’d be able to avoid the raw PHP stuff in dependencies.php.
Does anybody have any opinions/advice regarding such architecture decisions? Am I overzealous here? Is there a practical reason for keeping the raw PHP code in dependencies.php?
Thanks in advance!