PHP Classes

PHP Module Loader: Load modular classes by name

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 155 All time: 9,027 This week: 660Up
Version Licenses PHP version Categories
module-loader 1.0BSD License, GNU ...5.0PHP 5, Language
Description 

Author

This class can load modular classes by name.

It can take the name of a given module and loads the respective class from the modules directory.

The module class object is instantiated and returned to the application.

The class can also unload loaded modules, as well return the list of available modules.

Picture of Nick Daniels
  Performance   Level  
Name: Nick Daniels <contact>
Classes: 13 packages by
Country: United States United States
Age: 34
All time rank: 1107160 in United States United States
Week rank: 227 Up23 in United States United States Up
Innovation award
Innovation award
Nominee: 4x

Winner: 1x

Example

<?php
/**
 * A simple Module loader.
 * --------------------
 * Devel: Nick Daniels
 * Twttr: @ManicSec
 */
 
require_once 'Module.class.php';

###
## Start an instance of ModuleLoader
$module = ModuleLoader::startInst();

###
## Load a module by name `example`
$example = $module->loadModule("example");

###
## Check if Module loaded `example`
if(is_object($example) &&
   
$example->module_loaded())
    echo
"\r\nModule loaded!\r\n";
print_r($module->listModules());

###
## Unload Module, check if unloaded
if($module->unloadModule("example"))
    echo
"\r\nModule unloaded!\r\n";
print_r($module->listModules());


  Files folder image Files (3)  
File Role Description
Files folder imagemodules (1 directory)
Accessible without login Plain text file example.php Example Example Implementation
Plain text file Module.class.php Class A simple Module Loader

  Files folder image Files (3)  /  modules  
File Role Description
Files folder imageexample (1 file)

  Files folder image Files (3)  /  modules  /  example  
File Role Description
  Plain text file example.php Class Example Module File

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 0%
Total:155
This week:0
All time:9,027
This week:660Up