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 and the UniversalClassLoader for instance) but also around any other autoloader following this convention (the Composer one for instance) $loader = new ClassLoader(); register classes with namespaces $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();
<?php

require_once __DIR__ . '/vendor/symfony/class-loader/Psr4ClassLoader.php';
require_once __DIR__ . '/vendor/symfony/class-loader/WinCacheClassLoader.php';
use MF\App;
use MF\Render\MessageRender;
use Symfony\Component\ClassLoader\Psr4ClassLoader;
use Symfony\Component\ClassLoader\WinCacheClassLoader;
$loader = new Psr4ClassLoader();
$loader->addPrefix('MF', __DIR__ . '/src');
$loader = new WinCacheClassLoader('cache.prefix', $loader);
$loader->register();
$app = new App(new MessageRender('Hello world by WinCacheClassLoader!'));
$app->renderResponse();