Login   Register  
PHP Classes
elePHPant
Icontem

phpPlugin: Dynamically extend a PHP class using plug-ins

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Info   View files View files (5)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings  
2004-06-13 (10 years ago) RSS 2.0 feedStarStarStar 52%Total: 2,968 This week: 2All time: 1,144 This week: 930Up
Version License Categories  
phpplugin 1.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: 32
All time rank: 97170 in Brazil Brazil
Week rank: 790 Up66 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:2,968All time:1,144
 This week:2This week:930Up
 User Ratings  
 
 All time
Utility:73%StarStarStarStar
Consistency:75%StarStarStarStar
Documentation:-
Examples:80%StarStarStarStarStar
Tests:-
Videos:-
Overall:52%StarStarStar
Rank:1479