wwtg99 / class_loader
Installs: 50
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/wwtg99/class_loader
Requires
- php: >=5.6
- symfony/class-loader: ~3.0
Requires (Dev)
- phpunit/phpunit: ~5.2
This package is not auto-updated.
Last update: 2025-10-12 01:18:55 UTC
README
Description
Load class file automatically with namespace. Based on Symfony Psr4ClassLoader.
Usage
If directory is as below:
- src
- TestClass
- Test1.php (Class Test1, namespace TestClass)
- Sub
- Test2.php (Class Test2, namespace TestClass\Sub
- TestClass
$register_path =[
['TestClass', 'TestClass', true], //[prefix, path, recursive], directory with first letter upper case will be loaded recursively.
];
$loader = new \ClassLoader\Loader(*path_to_src*, $register_path);
$loader->autoload();
// Class Test1 and Test2 do not need require
$test1 = new \TestClass\Test1();
$test2 = new \TestClass\Sub\Test2();