for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types = 1);
namespace HDNET\Autoloader\Cache;
use TYPO3\CMS\Core\Core\Environment;
use TYPO3\CMS\Core\Utility\GeneralUtility;
/**
* AutoloaderFileBackend.
*
* Note: This backend is usable without the caching framework
*/
class AutoloaderFileBackend extends \TYPO3\CMS\Core\Cache\Backend\AbstractBackend
{
* {@inheritdoc}
public function set($entryIdentifier, $data, array $tags = [], $lifetime = null)
if (\is_array($data)) {
$cacheFile = $this->getCacheFileName($entryIdentifier);
GeneralUtility::writeFile($cacheFile, '<?php return ' . var_export($data, true) . ';');
}
return null;
public function get($entryIdentifier)
if ($this->has($entryIdentifier)) {
$content = include $this->getCacheFileName($entryIdentifier);
return $content;
public function has($entryIdentifier)
return is_file($this->getCacheFileName($entryIdentifier));
public function remove($entryIdentifier)
public function flush(): void
$files = glob(Environment::getVarPath() . '/autoloader_*');
foreach ($files as $file) {
unlink($file);
public function collectGarbage()
// Write by Loader::class
protected function getCacheFileName($entryIdentifier): string
return Environment::getVarPath() . '/autoloader_' . $entryIdentifier . '.php';