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 All time: 6,009 This week: 455Up
Version License PHP version Categories
manager_class 1.0BSD License5.0PHP 5, Language


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: 3347445 in United States United States
Week rank: 286 Up34 in United States United States Up
Innovation award
Innovation award
Nominee: 1x


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  
This week:0
All time:6,009
This week:455Up
 User Ratings  
 All time