Automatically loads PHP files from a given path based on a modular separator.
aLoad ('a' abbr. for auto) is a flexible auto file loader primarily based on a modular separator.
This script requires no additional frameworks or libraries.
Use your CLI and enter the following to clone:
git clone https://github.com/thielicious/aLoad.git
aLoad::register(array module || aLoad::ALL, [string folderpath]);
Simply register modules and define the foldername if your PHP classes reside in a different directory.
- modules are separated file contents. Usually classes are named "class" e.g. email.class.php and additional code that is included are called "inc" e.g. utilities.inc.php. Feel free to name them however you want.
- If you don't want to use modules, you may use the constant "aLoad::ALL" as the first parameter to register all PHP scripts which have no modules.
- Leave the parameter for the foldername blank if your scripts are in your root directory.
- Feel free to remove or change the namespace.
require_once "scripts/aLoad.class.php";
aLoad::register(["class", "inc"], "scripts/");
This example above will register all PHP files containing the module name "class" and "inc" in the folder "scripts".
require_once "aLoad.class.php";
aLoad::register(aLoad::ALL);
This above will register all PHP files without modules in your root directory.