2017 © Pedro PelĂĄez
 

library autoloader

Best autoloader from out there

image

crodas/autoloader

Best autoloader from out there

  • Friday, September 29, 2017
  • by crodas
  • Repository
  • 4 Watchers
  • 10 Stars
  • 1,221 Installations
  • PHP
  • 5 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 25 Versions
  • 1 % Grown

The README.md

Autoloader Build Status

Autoloader generator for PHP., (*1)

Why?

Autoloaders are cool, but every project comes with their own autoloader. Your project ends up having more autoloader than proper code., (*2)

I'm a pragmatic developer, and I don't believe that's fair that we spend in our production environment, where files barely changes comparing to the number of executions, executing autoloaders over and over., (*3)

So as a proof of concept I started this project, that aims to generate an efficient autoloader. The generated autoloader has an array of classes and files. As an extra gift, the generated code will have a generic PSR-0 autoloader (borrowed from @alganet)., (*4)

The autoloader now generates also loads all the class dependencies (parent classes, interfaces) in order to reduce the number of calls to the autoloaders., (*5)

Some features

  • No class to path transformation is done at run time. Autoloader creates a map of files and classes in a given directory.
  • When a class is loaded, all its dependencies are loaded (parent classes, interfaces). The goal is to reduce the number of calls to the autloader.
  • Always generate code that works with absolute paths (is --library is set, __DIR__ is being used instead)
  • Includes (except with the --library) a generic PSR-0 autoloader.

How it works

It was designed to be integrated in your deployment scripts., (*6)

require "lib/Autoloader/loader.php";

$generator = new \Autoloader\Generator("vendors/");
$generator->generate("autoloader.php");

Or if you know what you're doing, you can use an instance of Finder., (*7)

require "lib/Autoloader/loader.php";
$finder = \Symfony\Component\Finder\Finder();
$finder->files()->name('*.php')->in("vendors/");

$generator = new \Autoloader\Generator($finder);
$generator->generate("autoloader.php");

How to install (for developers)

In order to install you should use composer., (*8)

php composer.phar install

Using with composer

Composer is a great dependency manager, however I believe there is a lot of room for optimization in terms of autoloader generation. If you wish to have a better autoloader, one that can scan all your dependencies and your project (Whether they have configure the psr-0 or not). It will also add your local clases to the autoloader., (*9)

{
  "require": {
    "crodas/autoloader":"*"
  },
  "minimum-stability": "dev",
  "scripts": {
    "post-autoload-dump": "Autoloader\\Composer::generate"
  }
}

By overriding the post-autoload-dump it will replace the generated autoloader file, it will be called automatically however if you want to re-run it (for instance when you add a new class in your project and wish to be autoloaded) just run composer dump-autoload., (*10)

The Versions

29/09 2017
31/03 2016

dev-master

9999999-dev

Best autoloader from out there

  Sources   Download

BSD-4-Clause

The Requires

 

The Development Requires

by CĂ©sar D. Rodas

31/03 2016

v0.1.19

0.1.19.0

Best autoloader from out there

  Sources   Download

BSD-4-Clause

The Requires

 

The Development Requires

by CĂ©sar D. Rodas

25/03 2016

v0.1.18

0.1.18.0

Best autoloader from out there

  Sources   Download

BSD-4-Clause

The Requires

 

by CĂ©sar D. Rodas

18/02 2016

v0.1.17

0.1.17.0

Best autoloader from out there

  Sources   Download

BSD-4-Clause

The Requires

 

by CĂ©sar D. Rodas

20/06 2015

v0.1.16

0.1.16.0

Best autoloader from out there

  Sources   Download

BSD-4-Clause

The Requires

 

by CĂ©sar D. Rodas

20/06 2015
13/06 2015
04/05 2015
03/05 2015
03/05 2015
12/02 2015

v0.1.10

0.1.10.0

Best autoloader from out there

  Sources   Download

BSD-4-Clause

The Requires

 

by CĂ©sar D. Rodas

30/06 2014

v0.1.9

0.1.9.0

Best autoloader from out there

  Sources   Download

BSD-4-Clause

The Requires

 

by CĂ©sar D. Rodas

30/06 2014

v0.1.8

0.1.8.0

Best autoloader from out there

  Sources   Download

BSD-4-Clause

The Requires

 

by CĂ©sar D. Rodas

09/12 2013

dev-feature/improve-code

dev-feature/improve-code

Best autoloader from out there

  Sources   Download

BSD-4-Clause

The Requires

 

by CĂ©sar D. Rodas

09/12 2013

v0.1.7

0.1.7.0

Best autoloader from out there

  Sources   Download

BSD-4-Clause

The Requires

 

by CĂ©sar D. Rodas

02/11 2013

v0.1.6

0.1.6.0

Best autoloader from out there

  Sources   Download

BSD-4-Clause

The Requires

 

by CĂ©sar D. Rodas

24/10 2013

v0.1.5

0.1.5.0

Best autoloader from out there

  Sources   Download

BSD-4-Clause

The Requires

 

by CĂ©sar D. Rodas

24/10 2013

v0.1.4

0.1.4.0

Best autoloader from out there

  Sources   Download

BSD-4-Clause

The Requires

 

by CĂ©sar D. Rodas

24/10 2013

dev-feature/crodas/class-info

dev-feature/crodas/class-info

Best autoloader from out there

  Sources   Download

BSD-4-Clause

The Requires

 

by CĂ©sar D. Rodas

13/10 2013

v0.1.3

0.1.3.0

Best autoloader from out there

  Sources   Download

BSD-4-Clause

The Requires

 

by CĂ©sar D. Rodas

24/09 2013

v0.1.2

0.1.2.0

Best autoloader from out there

  Sources   Download

BSD-4-Clause

The Requires

 

by CĂ©sar D. Rodas

30/08 2013

v0.1.1

0.1.1.0

Best autoloader from out there

  Sources   Download

BSD-4-Clause

The Requires

 

by CĂ©sar D. Rodas

07/08 2013

v0.1.0

0.1.0.0

Best autoloader from out there

  Sources   Download

BSD-4-Clause

The Requires

 

by CĂ©sar D. Rodas

14/10 2012

dev-namespace-loader

dev-namespace-loader

Best autoloader from out there

  Sources   Download

The Requires

 

by CĂ©sar D. Rodas