PHP Classes

phpPlugin: Dynamically extend a PHP class using plug-ins

Recommend this page to a friend!
     
  Info   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStar 53%Total: 3,038 All time: 1,207 This week: 40Up
Version License Categories
phpplugin 1.0.0Freely DistributableLanguage, Code Generation
Description 

Author

This class is meant to dynamically extend any object of a class with new plug-in functions or collections of functions that are defined in separate files or from variables.

It works by dynamically creating a new sub-class of the class of given object adding the plug-in functions that are specified at runtime.

The name of the loaded plugin functions are stored in the object to prevent loading the same plugin more than once, but you still can force a reload so a new plugin can replace an old one.

Innovation Award
PHP Programming Innovation award nominee
June 2004
Number 2


Prize: One copy of the Zend Studio
The usual method for extending a class to add new functionality without having to change the class code is to create a subclass with new functions and variables that implement the new functionality.

However, if several people extend the same class with their own subclasses, it is difficult benefit from extensions developed by different people because their subclasses are separated.

This class implements a very innovative solution for extending a class using independent plug-in functions. It works by generating a new subclass that combines multiple functions that are defined in separate script files.

This way any developer may create a new class extension combining the functions defined by the plug-ins that they are interested, providing a more flexible and thus more powerful means of code reuse.

Manuel Lemos
Picture of David Bittencourt
Name: David Bittencourt <contact>
Classes: 1 package by
Country: Brazil Brazil
Age: 42
All time rank: 106073 in Brazil Brazil
Week rank: 178 Up11 in Brazil Brazil Up
Innovation award
Innovation award
Nominee: 1x

  Files folder image Files (5)  
File Role Description
Files folder imageplugins (2 files)
Accessible without login Plain text file example.php Example Example script
Plain text file plugin.class.php Class Main class
Accessible without login Plain text file test.php Example test.php

  Files folder image Files (5)  /  plugins  
File Role Description
  Accessible without login Plain text file bar.func.php Aux. Plugin bar() for test.php and example.php
  Accessible without login Plain text file bar.php Aux. Different bar() plugin for test.php and example.php

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  
 0%
Total:3,038
This week:0
All time:1,207
This week:40Up
 User Ratings  
 
 All time
Utility:75%StarStarStarStar
Consistency:76%StarStarStarStar
Documentation:-
Examples:79%StarStarStarStar
Tests:-
Videos:-
Overall:53%StarStarStar
Rank:2277