PHP Classes

Xtends: Emulates multiple inheritance of classes

Recommend this page to a friend!
  Info   Screenshots   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2024-01-09 (9 months ago) RSS 2.0 feedNot enough user ratingsTotal: 149 All time: 9,098 This week: 660Up
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: 215 Up7 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 (1)  
  • Xtends_graphic.jpg
  Files folder image Files (12)  
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 (12)  /  app  
File Role Description
  Plain text file Myclass.php Class app Class
  Plain text file Myclass2.php Class app Class

  Files folder image Files (12)  /  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

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 91%
Total:149
This week:0
All time:9,098
This week:660Up