Multiple Inheritance – XTends

August 1, 2013 by: Xavier Perez

PHP can’t do multiple inheritance as :

class MyClass extends Base_controller, Another_controller

Interfaces doesn’t solve the problem, namespaces solve partialy, and traits it’s only an approach.

Most of my developments have common classes, but every project have it’s own particularities.
I make developments under MVC concept, and all controllers have an inheritance from a Core_Controller, all models an inheritance from Core_Model, and so on…

What to do if I have a model like ‘Products_Model.php’ and it’s 90% of code that I can re-use for another projects ? Must I copy this to my created project ? Will I have new changes made in the original Products_Model ?

Could I inherit from it’s methods and change/develop my own method for my new project ? I CAN’T DO !!!

But… there is a solution… XTends.

With XTends I can have a ‘Product_model’ inheriting from another ‘Product_model’, and also from my Core_Model

 

Visit:  PHPClasses – XTends

Bitbucket:  Xtends Repository

Demo:  Demo online

 

Filed under: Other

Leave a Reply

You must be logged in to post a comment.