obf/classloader

The Opsbears Framework Classloader Component

This package's canonical repository appears to be gone and the package has been frozen as a result.

v1.0.8 2015-12-14 08:32 UTC

This package is not auto-updated.

Last update: 2020-06-12 18:00:37 UTC


README

Build Status Coverage Status Dependency Status Latest Stable Version License

This is the base component of the Opsbears Framework, which loads classes. It builds upon the SPL autoload facility and can be connected to the composer autoloader.

It has been built to facilitate better error messages in case of autoloading errors, as well as some additional features, such as iClassLoadListener, which is the OBF counterpart of Java static constructors.

Documentation

The API documentation is available at opsbears.github.io/obf-classloader.

Requirements

Since the OBF classloader uses namespaces, the minimum required PHP version is 5.3.0, but it contains support for traits as well. It also requires the PCRE extension to work. For other OBF components, however, 5.4.0 is the minimum required version because they actively use traits.

Usage

Composer

If you are using composer, you can pull in the classloader as a dependency doing this:

composer require obf/classloader

Manual loading

If you are using some other dependency manager, use the src directory as a root for OBF\Classloader like this:

require_once('/path/to/obf/classloader/src/ClassLoader.php');

//Add own path
ClassLoader::addClassPath('/path/to/obf/classloader/src', 'OBF\\ClassLoader');

//Register az SPL autoloader
ClassLoader::register();

This will enable the classloader.