Imitating Multiple Inheritance in PHP
- by fabieno
I am working on my own MVC framework and found myself stuck.
I need the following construction:
Controller
-- Backend_Controller
-- Backend_Crud_Controller
-- Frontend_Controller
-- Frontend_Crud_Controller
Both 'Backend_Crud_Controller' and 'Frontend_Crud_Controller' have the same functionality and thus they should extend another class named 'Base_Crud_Controller', the only difference comes from the 'Backend/Frontend' Controllers which implement different mechanisms.
Basically they should inherit both classes but my problem is that 'Backend/Frontend' controller doesn't necessarily extend 'Base_Crud_Controller'.
I know multiple inheritance doesn't exist in PHP but I am looking for a solution, I choose to refrain Mixins (like in Symfony) as I don't consider that an elegant solution.
Interfaces do not suit me as all of these end up as concrete classes that should implement methods.