Background
I am trying to design a reasonably useful MVC framework from scratch primarilty for my own education before jumping into Laravel/Symfony.
I am trying to implement dependency injection because plan on expanding this framework in the future and I want to keep things modular and maintainable.
Here is the MVC repository: https://github.com/JethroHazelhurst/psr-4-mvc
(Note: the controller/routing system is hard coded for simplicity!)
Here is my flowchart showing how the MVC framework is structured without dependency injection.
As I understand it, the main dependencies are...
- Core\Router depends on Foo\Controller
- FooController depends on Core\Controller (via the parent::__construct method)
- Core\Controller depends on Core\View
- Foo_Model depends on Core\model which depends on Core\Database
Questions
So I am a bit confused as to how I should use dependency injection here... for example: How do I implement dependency injection with parent::__constructors (if at all)?
Also, is depending on parent::__construct like this making the framework too tightly coupled?
Many thanks in advance for your considered reply.