2017 © Pedro Peláez
 

library koloader

A lightweight directory-sniffing autoloader with caching.

image

smuuf/koloader

A lightweight directory-sniffing autoloader with caching.

  • Thursday, January 28, 2016
  • by smuuf
  • Repository
  • 1 Watchers
  • 2 Stars
  • 506 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 2 % Grown

The README.md

Koloader

Koloader is a super-lightweight directory-sniffing autoloader with caching., (*1)

Installation

You probably want to do either of these:, (*2)

  1. Direct download or
  2. With Composer: composer require smuuf/koloader

Usage

Koloader is created with ease-of-use in mind. Really, you will need only four lines of code in your new project. The rest will be handled for you., (*3)

First, include the Koloader in your project

Koloader needs to be included first. If you're not using Composer, this can be done directly by including the Koloader's loader script, which will load everything else that is needed:, (*4)

require __DIR__ . "/path/to/Koloader/src/loader.php";
And then use it!
$loader = new \Smuuf\Koloader\Autoloader(__DIR__ . "/temp/"); // The temp directory must exist beforehand.
$loader->addDirectory(__DIR__ . "/app")
    ->register();

// Autoloading is enabled now!

$instance = new SomeClass; // Autoloading will be handled by the Koloader.
$instance->doClassStuff(); // Profit!

The Koloader must be instantiated with a path to an existing temporary directory as an argument: - Autoloader::__construct(string $pathToTmpDir) - Specified directory will be used for storing cached maps of scanned files. This directory will not be created automatically and thus must exist beforehand., (*5)

And then you need to call only two methods on the Koloader instance: - Autoloader::addDirectory(string $pathToDirectory) - Add a directory to the list of directories that will be scanned for definitions of autoloadable tokens (those good ol' class, interface, trait keywords) - Autoloader::register() - Call this after all directories were added. This will register the Koloader and from that moment it will handle autoloading., (*6)

That is all. Have fun!, (*7)

The Versions

28/01 2016

dev-master

9999999-dev

A lightweight directory-sniffing autoloader with caching.

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

28/01 2016

0.1

0.1.0.0

A lightweight directory-sniffing autoloader with caching.

  Sources   Download

MIT

The Requires

  • php >=5.5.0