Documentation

XcacheClassLoader
in package

XcacheClassLoader implements a wrapping autoloader cached in XCache for PHP 5.3.

It expects an object implementing a findFile method to find the file. This allows using it as a wrapper around the other loaders of the component (the ClassLoader for instance) but also around any other autoloaders following this convention (the Composer one for instance).

// with a Symfony autoloader
$loader = new ClassLoader();
$loader->addPrefix('Symfony\Component', __DIR__.'/component');
$loader->addPrefix('Symfony',           __DIR__.'/framework');

// or with a Composer autoloader
use Composer\Autoload\ClassLoader;

$loader = new ClassLoader();
$loader->add('Symfony\Component', __DIR__.'/component');
$loader->add('Symfony',           __DIR__.'/framework');

$cachedLoader = new XcacheClassLoader('my_prefix', $loader);

// activate the cached autoloader
$cachedLoader->register();

// eventually deactivate the non-cached loader if it was registered previously
// to be sure to use the cached one.
$loader->unregister();
Tags
author

Fabien Potencier fabien@symfony.com

author

Kris Wallsmith kris@symfony.com

author

Kim Hemsø Rasmussen kimhemsoe@gmail.com

deprecated

since version 3.3, to be removed in 4.0. Use composer install --apcu-autoloader instead.

Table of Contents

$decorated  : mixed
$prefix  : mixed
__call()  : mixed
Passes through all unknown calls onto the decorated object.
__construct()  : mixed
findFile()  : string|null
Finds a file by class name while caching lookups to Xcache.
loadClass()  : bool|null
Loads the given class or interface.
register()  : mixed
Registers this instance as an autoloader.
unregister()  : mixed
Unregisters this instance as an autoloader.

Properties

Methods

__call()

Passes through all unknown calls onto the decorated object.

public __call(mixed $method, mixed $args) : mixed
Parameters
$method : mixed
$args : mixed
Return values
mixed

__construct()

public __construct(string $prefix, object $decorated) : mixed
Parameters
$prefix : string

The XCache namespace prefix to use

$decorated : object

A class loader object that implements the findFile() method

Tags
throws
RuntimeException
throws
InvalidArgumentException
Return values
mixed

findFile()

Finds a file by class name while caching lookups to Xcache.

public findFile(string $class) : string|null
Parameters
$class : string

A class name to resolve to file

Return values
string|null

loadClass()

Loads the given class or interface.

public loadClass(string $class) : bool|null
Parameters
$class : string

The name of the class

Return values
bool|null

True, if loaded

register()

Registers this instance as an autoloader.

public register([bool $prepend = false ]) : mixed
Parameters
$prepend : bool = false

Whether to prepend the autoloader or not

Return values
mixed

unregister()

Unregisters this instance as an autoloader.

public unregister() : mixed
Return values
mixed

Search results