PHP Classes

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    
Ratings Unique User Downloads Download Rankings
StarStarStar 47%Total: 472 This week: 1All time: 6,007 This week: 560Up
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
Picture of TB
  Performance   Level  
Name: TB <contact>
Classes: 1 package by
Country: United States United States
Age: ???
All time rank: 3343446 in United States United States
Week rank: 411 Up48 in United States United States Up
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:472
This week:1
All time:6,007
This week:560Up
 User Ratings  
 
 All time
Utility:50%StarStarStar
Consistency:75%StarStarStarStar
Documentation:75%StarStarStarStar
Examples:75%StarStarStarStar
Tests:-
Videos:-
Overall:47%StarStarStar
Rank:3021