2017 © Pedro Peláez
 

library class-loader-adapter

The Class Loader Adapter provides a common interface to interact with a number of different class loaders.

image

robloach/class-loader-adapter

The Class Loader Adapter provides a common interface to interact with a number of different class loaders.

  • Thursday, July 18, 2013
  • by RobLoach
  • Repository
  • 1 Watchers
  • 1 Stars
  • 0 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 4 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Class Loader Adapter

Common interface to interact with a number of different class loaders., (*1)

Design

It is recommended to just have one class loader interface for your application, and initialize and use it only once during your application's starting point. It can, however, sometimes be handy to allow swapping the class loader while still using the same API to interact with it. Class Loader Adapter aims to provide that interface commonality between a bunch of different third-party class loaders., (*2)

Interoperability

Usage

Initialize with whichever class loader you want to use:, (*3)

// Initialize the loader with the Symfony UniversalClassLoader.
$loader = new RobLoach\ClassLoaderAdapter\Symfony\UniversalClassLoader();

// Initialize the loader with the Composer ClassLoader.
$loader = new RobLoach\ClassLoaderAdapter\Composer\ClassLoader();

Since all of the Class Loader Adapter loaders use the same ClassLoaderInterface , you can interact with them all the same way., (*4)

// Add a namespace prefix.
$loader->addPrefix('Foo', 'src/');

// Add a class map.
$map = array('Foo\Bar' => 'src/Foo/Bar.php');
$loader->addClassMap($map);

// Register the class loader so that the classes can be loaded accordingly.
$loader->register();

Although the interface is in place, class loader functionality and support slightly differs from class loader to class loader. Take note of this when switching between the class loaders., (*5)

The Versions

18/07 2013

dev-master

9999999-dev http://github.com/robloach/class-loader-adapter

The Class Loader Adapter provides a common interface to interact with a number of different class loaders.

  Sources   Download

MIT

The Requires

  • php >=5.3.3

 

The Development Requires