Ratings | | Unique User Downloads | | Download Rankings |
Not enough user ratings | | Total: 139 | | All time: 9,229 This week: 660 |
|
Description | | Author |
This package can autoload classes based on PSR-4 recommendation.
There is an autoloader class that can load classes based on path of a specific directory that is associated to a given namespace.
It registers a given namespace and associate it to a given auto-loading directory. The class also registers sub-directories and associate them to sub-namespaces. Innovation Award
February 2016
Number 12 |
PSR-4 is a recommendation by the FIG (Framework Interoperability Group) that defines how package classes should be automatically loaded according to given namespaces that are associated to certain directories.
This class extends the recommendations of PSR-4 by defining a class autoloader that not only associates a given directory to a certain namespace, but also associates sub-directories to sub-namespaces.
Manuel Lemos |
| |
|
|
Innovation award
Nominee: 7x
Winner: 1x |
|
Example
<?php
/**
* Registers a new registrar for the autoloader, this file is part of Plug-Autoloader.
*
* @see ./autoloader.php For a description of what this project is all about
* and how it works.
* @author Samuel Adeshina <samueladeshina73@gmail.com>
* @version 1.0
* @since 0.0.1 1st January, 2016
* @copyright 2015 - 2016 Samuel Adeshina <samueladeshina73@gmail.com> <http://samshal.github.io>
* @license MIT
*/
require __DIR__ . "/autoloader_register.php";
/**
* We need to specify the location of the configuration file.
* It can be an xml or a json file and it can be located anywhere.
* @see AutoloadeRegister::ParseConfigFile() For a detailed explanation of this
*
* It is advised to set this location to the document root, that is the root level folder
*
* The default is the root level folder, but... feel free to change it to any other location as
* you see fit.
*/
$base_directory_minus_file_name = $_SERVER["DOCUMENT_ROOT"]. DIRECTORY_SEPARATOR;
$config_file_name_minus_extension = "autoload";
if (file_exists($base_directory_minus_file_name. $config_file_name_minus_extension.".json"))
{
$configuration_file = $base_directory_minus_file_name. $config_file_name_minus_extension.".json";
}
else if (file_exists($base_directory_minus_file_name. $config_file_name_minus_extension.".xml"))
{
$configuration_file = $base_directory_minus_file_name. $config_file_name_minus_extension.".xml";
}
else
{
return;
}
new Plug\Autoloader\AutoloaderRegister($configuration_file, $base_directory_minus_file_name);
?>
|
Details
Plug-Loader
About
A PSR4 Implementation of an autoloader for the ~Plug Microframework.
How-TO
> The configuration file for this autoloader can be __supplied in two different formats__:
> It can be provided as a json file or as an xml file.
The Autoloader first checks for a json file before xml since thats the default config format.
You must create an xml autoload configuration file in the document root in order to use xml for the config format.
You can rename the autoload.xml.template file to autoload.xml after the autoload.json file has been deleted or renamed to
test this.
|
Applications that use this package |
|
No pages of applications that use this class were specified.
If you know an application of this package, send a message to the author to add a link here.