slender / module-loader
Simple, de-coupled application modules
Installs: 17
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 1
Open Issues: 0
pkg:composer/slender/module-loader
Requires
- php: >=5.4.0
Requires (Dev)
- ext-curl: ~0.0
- mockery/mockery: ~0.9
- phpunit/phpunit: ~4.4
- satooshi/php-coveralls: ~0.6
This package is not auto-updated.
Last update: 2025-10-21 07:30:29 UTC
README
Simple Module loading for decoupled application components
Installation
Install via composer:
composer require slender/module-loader
Usage
<?php use \Slender\ModuleLoader\ModuleLoader; use \Slender\ModuleLoader\ModuleInterface; $app = new \Slim\App(); /** * An example module class */ class MyModule implements ModuleInterface { public function invokeModule( \Slim\App $slim ) { $slim->get('/foo',function(){ /* ... */ }); } } // Create the module loader instance $moduleManager = new SimpleModuleLoader(); // Try to load the module $moduleManager->loadModule('\Acme\Example\MyModule', $slim);
Module Locators
Module Locators are responsible for translating a module identifier string into a callable object that can be invoked to load the module. Module Locators must implement Slender\ModuleLoader\ModuleLocatorInterface
ModuleManager includes two default Locators, which are loaded by default when using the SimpleModuleLoader.
Slender Module Locator
Slender\ModuleLoader\Locator\SlenderModuleLocator
This locator will use the module identifier as a fully-qualified class name and attempt to load the class as long as it implements Slender\ModuleLoader\ModuleInterface.
Invokable Class Locator
Slender\ModuleLoader\Locator\InvokableClassModuleLocator
This locator will use the module identifier as a fully-qualified class name and attempt to load the class and then invoke it.