PHP Classes

Xtends: Emulates multiple inheritance of classes

Recommend this page to a friend!
  Info   Screenshots Screenshots   View files View files (11)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2024-01-09 (2 months ago) RSS 2.0 feedNot enough user ratingsTotal: 147 All time: 9,099 This week: 117Up
Version License PHP version Categories
xtends 1.0MIT/X Consortium ...5.3PHP 5, Language
Description 

Author

This package emulates multiple inheritance of functionality of classes.

A loader class can be used to load and call separate objects that provide additional functionality thus extending the functionality of a base class.

Calls to functions or accesses to variables that are not supported by the main class are delegated on separated objects.

Picture of Xavier Pérez
  Performance   Level  
Name: Xavier Pérez is available for providing paid consulting. Contact Xavier Pérez .
Classes: 9 packages by
Country: Spain Spain
Age: ???
All time rank: 132727 in Spain Spain
Week rank: 312 Up10 in Spain Spain Up
Innovation award
Innovation award
Nominee: 1x

Details

# XTends Multiple inheritance for PHP5 Multiple inheritanhe it's not possible with PHP, only Symfony have an approach called Mixins. Many frameworks have a Base_controller and all controllers inherit from it. When you have a controller that have common methods, but you want to change few lines of this class, you must to edit it or duplicate it in another class. With Xtends you can have all common functionality inherit from Base_controller and own functionality, added, overrided or partialy overrided. ## How it work's Normally, your controller (we are using Myclass for this example), extend from a Base_controller: ```python class Myclass extends Base_controller ``` Xtends add a intermediate class to allow multiple inheritance: ```python class Myclass extends Base_loader ``` When you load your Myclass.php, calls ```python $this->xtends_loader(__CLASS__,__FILE__); ``` This try to load same Myclass.php from another directory (BASEPATH), parse it and load as "MyClass_common" Method that exists in app/Myclass, takes precedence. Method that not exists in app/Myclass, but exists in base/Myclass, base/Myclas/Method are excuted. Method that not exists in app/Myclass, neither base/Myclass, but exists in Base_controller, is executed. In first demo (demoMyClassBase.php), a normal inheritance, Myclass extends Base_controller. Second demo (demoMyClassApp.php) is a copy of base/Myclass, show extended inheritance, located in app/MyClass. Trird demo (app/MyClass2), is an empty extend (app/MyClass2) from base/Myclass2. Online demo: [Demo](http://www.4amics.com/libraries/xtends/)

Screenshots  
  • Xtends_graphic.jpg
  Files folder image Files  
File Role Description
Files folder imageapp (2 files)
Files folder imagebase (4 files)
Plain text file demoMyClassApp.php Example DemoApp
Plain text file demoMyClassApp2.php Example DemoApp2
Plain text file demoMyClassBase.php Example DemoBase
Plain text file index.php Aux. Index.php
Plain text file readme.md Doc. readme

  Files folder image Files  /  app  
File Role Description
  Plain text file Myclass.php Class app Class
  Plain text file Myclass2.php Class app Class

  Files folder image Files  /  base  
File Role Description
  Plain text file Base_controller.php Class Base controller
  Plain text file Base_loader.php Class Base loader
  Plain text file Myclass.php Class base Class
  Plain text file Myclass2.php Class base Class

 Version Control Unique User Downloads Download Rankings  
 91%
Total:147
This week:0
All time:9,099
This week:117Up