PSR-4 compliant autoloader for PHP 5.3 or higher

1.0.3 2015-03-24 07:44 UTC


Build Status Dependency Status

What Is Gleez Autoloader?

The Gleez Autoloader package provides a PSR-4 compliant SPL autoloader implementation for PHP 5.3 or higher loosely based on the Zend PSR-0 compliant StandardAutoloader with some improvements and additions.

This package is compliant with PSR-0, PSR-1, PSR-2 and PSR-4. If you notice compliance oversights, please send a patch via pull request.


Tested PHP versions

  • 5.3.x
  • 5.4.x
  • 5.5.x
  • 5.6.x
  • 7.x
  • hhvm

Additional requirements

  • PHPUnit 4.0.0 or higher (for testing)
  • PHP_CodeSniffer 2.x or higher (for testing)


Provides autoloading classes by checking their name and search files in the file system.

Supports the following strategies:

  • Load from include_path (fallback-mode)
  • Load from a list of Namespace => Path pairs
  • Load from a list of Prefix => Path pairs


Git way

$ git clone

Composer way

Download and install composer from

$ curl -sS | php

Add the following to your project composer.json file:

    "require": {
        "gleez/autoloader": "dev-master"

When you're done just run

$ php composer.phar install

and the package is ready to be used. Another way, if you already have composer:

$ composer require --prefer-source gleez/autoloader:dev-master

Direct zipball download

Getting Started

// Creating an Autoloader object
$autoloader = new Autoloader();

// Creating an Autoloader object with some configuration
$autoloader = new Autoloader($config);

// Creating an Autoloader object with autoregister Gleez lib
$autoloader = new Autoloader(array('autoregister' => true));

// Simple way with one namespace
$autoloader->setNamespaces('Zend', '/usr/includes/Zend');

// Setting multiple namespaces
    'Aura\Web' => '/path/to/aura-web/src',
    'Gleez'    => '/path/to/Gleez'

// Enabling fallback-mode

// Simple way with one prefix
$autoloader->setNamespaces('Kohana_', '/path/to/Kohana/lib');

// Setting multiple prefixes
    'Phly_'  => '/path/to/Phly',
    'Gleez_' => '/path/to/Gleez',

// Register this instance as an autoloader

// Gets current prefixes and corresponding registered paths

// Gets current namespaces and corresponding registered paths


So, you want to contribute to the Gleez Autoloader project? Well of course you do! I guess that's pretty clear. I mean, anyone could tell, right?

Some things to watch out for:

  • Please do PR to next branch
  • Make sure that the code you write fits with the general style and coding standarts of the Accepted PHP Standards and PSR-4 autoloader
  • Your code should be easy to understand, maintainable, and modularized
  • Please test your changes before submitting to make sure that not only they work, but have not broken other parts of the Gleez Autoloader
  • If you do any API changes please follow Semantic Versioning 2.0.0


To run the tests at the command line, go to the tests directory and run phpunit:

$ composer install --dev --prefer-source
$ phpunit \
--configuration tests/phpunit.xml.dist \
--coverage-text \
--coverage-clover ../build/logs/clover.xml \
--coverage-html   ../build/report

For additional information see PHPUnit The Command-Line Test Runner


Licensed under the Gleez CMS License. © Gleez Technologies