2017 © Pedro Peláez
 

library phpautoloader

Joe's simple to use and versatile PHP autoloader.

image

joefallon/phpautoloader

Joe's simple to use and versatile PHP autoloader.

  • Wednesday, July 27, 2016
  • by jfallon
  • Repository
  • 1 Watchers
  • 0 Stars
  • 293 Installations
  • PHP
  • 9 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 13 Versions
  • 1 % Grown

The README.md

phpautoloader

By Joe Fallon, (*1)

Joe's PHP Autoloader is a versatile and easy to use autoloader for PHP 5.3 and greater. It provides the following features:, (*2)

  • When auto-loading a class, all of the include paths are searched automatically.
  • For maximum legacy support, non-namespaced classes are allowed.
  • Normal PSR-0 namespaced classes are supported.
  • Underscore namespaced (e.g. like the Zend Framework 1 or PEAR) classes are supported.
  • This autoloader is fast. No recursive directory searches are performed.

Requirements

The only requirement is PHP > 5.3.0. This is due to the use of namespaces. Additionally, Composer can be helpful., (*3)

Installation

The easiest way to install Joe's Autoloader is with Composer. Create the following composer.json file and run the php composer.phar install command to install it., (*4)

{
    "require": {
        "joefallon/phpautoloader": "*"
    }
}

Usage

To use Joe's Autoloader, the following initialization steps are needed:, (*5)

  • Add the base directories where classes can be found to the include path.
  • Call the Autoloader::registerAutoload() method to load the autoloader.
  • Start using classes in your code.
use JoeFallon\AutoLoader;

// Define the include paths.
define('BASE_PATH', realpath(dirname(__FILE__) . '/../'));
define('LIB_PATH',  BASE_PATH . '/lib');
define('VEND_PATH', BASE_PATH . '/vendor');

// Set the application include paths for auto-loading.
set_include_path(get_include_path() . ':' . LIB_PATH . ':' . BASE_PATH);

// Require the Composer autoloader. Composer will handle its own class auto-loading
// using its own autoloader.
require(VEND_PATH . '/autoload.php');

// Initialize Joe's Autoloader. Joe's Autoloader will handle auto-loading any classes
// that are not auto-loaded using Composer's built-in autoloader.
Autoloader::registerAutoLoad();

As long as namespaces are mapped to the folder structure within the directories defined above, then autoloader will have no problems finding and loading the classes., (*6)

For example, let's assume we want to load the class Bar that is within the file named Bar.php contained within a folder Foo. Also, let's assume that the class Bar is namespaced \Foo\Bar. This would give a file path of LIB_PATH/Foo/Bar.php. When new Bar(); is executed, the Bar class will be loaded (if is was not already)., (*7)

Here is a visual depiction of the above example:, (*8)

Joe's Autoloader Example, (*9)

The Versions

27/07 2016

dev-master

9999999-dev https://github.com/joefallon/phpautoloader

Joe's simple to use and versatile PHP autoloader.

  Sources   Download

MIT

simple autoloader namespace psr-0

27/07 2016

dev-develop

dev-develop https://github.com/joefallon/phpautoloader

Joe's simple to use and versatile PHP autoloader.

  Sources   Download

MIT

simple autoloader namespace psr-0

27/07 2016

v2.0.5

2.0.5.0 https://github.com/joefallon/phpautoloader

Joe's simple to use and versatile PHP autoloader.

  Sources   Download

MIT

simple autoloader namespace psr-0

27/12 2015

v2.0.4

2.0.4.0 https://github.com/joefallon/phpautoloader

Joe's simple to use and versatile PHP autoloader.

  Sources   Download

MIT

simple autoloader namespace psr-0

05/02 2015

v2.0.3

2.0.3.0 https://github.com/joefallon/phpautoloader

Joe's simple to use and versatile PHP autoloader.

  Sources   Download

MIT

simple autoloader namespace psr-0

28/12 2014

v2.0.2

2.0.2.0 https://github.com/joefallon/phpautoloader

Joe's simple to use and versatile PHP autoloader.

  Sources   Download

MIT

simple autoloader namespace psr-0

20/10 2014

v2.0.1

2.0.1.0 https://github.com/joefallon/phpautoloader

Joe's simple to use and versatile PHP autoloader.

  Sources   Download

MIT

simple autoloader namespace psr-0

20/10 2014

v2.0.0

2.0.0.0 https://github.com/joefallon/phpautoloader

Joe's simple to use and versatile PHP autoloader.

  Sources   Download

MIT

simple autoloader namespace psr-0

23/09 2014

v1.0.4

1.0.4.0 https://github.com/joefallon/phpautoloader

Joe's simple to use and versatile PHP autoloader.

  Sources   Download

MIT

simple autoloader namespace psr-0

29/08 2014

v1.0.3

1.0.3.0 https://github.com/joefallon/phpautoloader

Joe's simple to use and versatile PHP autoloader.

  Sources   Download

MIT

simple autoloader namespace psr-0

29/08 2014

v1.0.2

1.0.2.0 https://github.com/joefallon/PhpAutoloader

Joe's simple to use and versatile PHP autoloader.

  Sources   Download

MIT

php autoloader psr-0 kiss easy-to-use

11/07 2014

v1.0.1

1.0.1.0 https://github.com/joefallon/phpautoloader

Joe's simple to use and versatile PHP autoloader.

  Sources   Download

MIT

php autoloader psr-0 kiss easy-to-use

11/07 2014

v1.0.0

1.0.0.0 https://github.com/joefallon/phpautoloader

Joe's simple to use and versatile PHP autoloader.

  Sources   Download

MIT

php autoloader psr-0 kiss easy-to-use