awps / loader
Simple loader that is designed to work with both classes and normal PHP files.
1.0.1
2017-12-18 22:47 UTC
Requires
- php: >=5.3.0
This package is not auto-updated.
Last update: 2024-12-22 06:10:54 UTC
README
Loader
A simple loader that is designed to work with both classes and normal PHP files.
Installation
With composer:
composer require awps/loader
Manually:
require_once 'getloader.php';
Usage
Load PHP classes:
Awps\Loader::loadClasses( $path, $namespace );
This will autoload all PHP classes from $path
and will assume that the namespace in those classes is $namespace
;
Load simple PHP files:
Awps\Loader::loadFiles( $path, $pattern );
This will autoload all php files from $path
that contains $pattern
in their name.
Examples
// Autoload classes from `inc` folder and set the namespace to `Awesome` Awps\Loader::loadClasses( __DIR__ . 'inc', 'Awesome' ); // Now you can initialize a class. For example: new Awesome\Something(); // ------------------------------------------------------- // Include all php files from `functions` Awps\Loader::loadFiles( __DIR__ . 'functions', 'component-' ); // This one will include all php files that contains `component-` string in their name // from `functions` directory. // Now you may call a function defined in one of those files. For example: do_something_special();