2017 © Pedro Peláez
 

library autoload

JetFire - Autoload support PSR-4 convention

image

jetfirephp/autoload

JetFire - Autoload support PSR-4 convention

  • Tuesday, February 16, 2016
  • by jetfirephp
  • Repository
  • 1 Watchers
  • 2 Stars
  • 105 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

JetFire PSR-4 Autoloader

A PSR-4 autoloader., (*1)

Installation

Via composer, (*2)

composer require jetfirephp/autoload

Usage

To use the autoloader, first instantiate it, then register it with SPL autoloader stack:, (*3)

require_once __DIR__ . '/vendor/autoload.php';

$loader = new \JetFire\Autoloader\Autoload();

$loader->register();

Add Namespace

To add a single namespace here how to do this :, (*4)

$loader->addNamespace('App\Admin','/path/to/app-admin/src');
$loader->addNamespace('App\Admin','/path/to/app-admin/tests');

For multiple namespaces :, (*5)

$loader->setNamespaces([
    'App\Admin' => [
        '/path/to/app-admin/src',
        '/path/to/app-admin/tests'
    ],
    'App\Public' => '/path/to/app-public'
]);
// or
$loader->setNamespaces('/path/to/namespaces/file.php');

This will override all previous namespace settings., (*6)

Add Class

To map a class to a file, use the addClass() method., (*7)

$loader->addClass('App/Admin/Auth','/path/to/app-admin/Auth.php');

For multiple classes :, (*8)

$loader->setClassCollection([
    'App\Admin\Auth' => '/path/to/app-admin/Auth.php'
]);
// or
$loader->setClassCollection('path/to/classes/file.php');

Smart Autoloader

If you set a default base directory for your autoloader like this :, (*9)

$loader = new \JetFire\Autoloader\Autoload('/path/to/base/directory');

And you want to instantiate a class Auth.php with the namespace App\Admin when you have not define this namespace in addClass() method, JetFire\Autoloader will check if the file Auth.php exists in /path/to/base/directory/App/Admin/ folder., (*10)

License

The JetFire Autoloader is released under the MIT public license : http://www.opensource.org/licenses/MIT., (*11)

The Versions

16/02 2016

dev-master

9999999-dev

JetFire - Autoload support PSR-4 convention

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

by Sumugan Sinnarasa

loader autoload psr-4