WinCacheClassLoader deprecated
class WinCacheClassLoader
deprecated
WinCacheClassLoader implements a wrapping autoloader cached in WinCache.
It expects an object implementing a findFile method to find the file. This allow 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 WinCacheClassLoader('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();
Methods
__construct(string $prefix, object $decorated) | ||
register(bool $prepend = false) Registers this instance as an autoloader. | ||
unregister() Unregisters this instance as an autoloader. | ||
bool|null | loadClass(string $class) Loads the given class or interface. | |
string|null | findFile(string $class) Finds a file by class name while caching lookups to WinCache. | |
__call($method, $args) Passes through all unknown calls onto the decorated object. |
Details
__construct(string $prefix, object $decorated)
Parameters
string | $prefix | The WinCache namespace prefix to use |
object | $decorated | A class loader object that implements the findFile() method |
Exceptions
RuntimeException | |
InvalidArgumentException |
register(bool $prepend = false)
Registers this instance as an autoloader.
Parameters
bool | $prepend | Whether to prepend the autoloader or not |
unregister()
Unregisters this instance as an autoloader.
bool|null loadClass(string $class)
Loads the given class or interface.
Parameters
string | $class | The name of the class |
Return Value
bool|null | True, if loaded |
string|null findFile(string $class)
Finds a file by class name while caching lookups to WinCache.
Parameters
string | $class | A class name to resolve to file |
Return Value
string|null |
__call($method, $args)
Passes through all unknown calls onto the decorated object.
Parameters
$method | ||
$args |
© 2004–2017 Fabien Potencier
Licensed under the MIT License.
http://api.symfony.com/4.0/Symfony/Component/ClassLoader/WinCacheClassLoader.html