PHP Classes

phpPlugin: Dynamically extend a PHP class using plug-ins

Recommend this page to a friend!
  Info   View files View files (5)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStar 53%Total: 3,037 This week: 1All time: 1,208 This week: 571Up
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: 105873 in Brazil Brazil
Week rank: 420 Up38 in Brazil Brazil Up
Innovation award
Innovation award
Nominee: 1x

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

 Version Control Unique User Downloads Download Rankings  
 0%
Total:3,037
This week:1
All time:1,208
This week:571Up
 User Ratings  
 
 All time
Utility:75%StarStarStarStar
Consistency:76%StarStarStarStar
Documentation:-
Examples:79%StarStarStarStar
Tests:-
Videos:-
Overall:53%StarStarStar
Rank:2243