PHP Classes
elePHPant
Icontem

Manager Class: Load classes when a function is called

Recommend this page to a friend!
  Info   View files View files (5)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2011-10-10 (5 years ago) RSS 2.0 feedNot enough user ratingsTotal: 470 All time: 5,760 This week: 862Up
Version License PHP version Categories
manager_class 1.0BSD License5.0PHP 5, Language
Description Author

This class can load classes when a function is called.

It handles calls to non-existent functions by checking the name of the called function and loading a class with the same name including a script with derived name.

The name of the directory from where the class files are included is configurable.

If the called function includes an underscore character, the class also calls the class function with the name that follows the underscore character. Otherwise, the class calls the constructor function with the same name of the class.

Innovation Award
PHP Programming Innovation award nominee
October 2011
Number 9
Loading and initializing classes is often a tedious process that developers need to implement in their PHP scripts.

This manager class provides an alternative method that simplifies the process by loading a class automatically when a virtual function with the same name of the class to be loaded is called on the manager class.

The manager class takes care of both loading the classes and calling their initialization functions.

Manuel Lemos
  Performance   Level  
Name: TB <contact>
Classes: 1 package by
Country: Romania Romania
Innovation award
Innovation award
Nominee: 1x

Details
    A folder must exist in the same folder as the main class file
    that would contain the classes to be runed during the script execution.
    
    In the example , the classes :
    test.class.php
    test2.class.php
    should be contained by the folder classes/
  Files folder image Files  
File Role Description
Files folder imageclasses (2 files)
Accessible without login Plain text file Manager.class.php Class Manager Class File
Accessible without login Plain text file readme.txt Doc. Important readme file
Accessible without login Plain text file index.php Example Example file

  Files folder image Files  /  classes  
File Role Description
  Accessible without login Plain text file test.class.php Aux. An example class
  Accessible without login Plain text file test2.class.php Aux. A second example class

 Version Control Unique User Downloads Download Rankings  
 0%
Total:470
This week:0
All time:5,760
This week:862Up