PHP code example of thadafinser / speed-loader

1. Go to this page and download the library: Download thadafinser/speed-loader library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

thadafinser / speed-loader example snippets


// composer autoloading
ways needed, exclude all classes loaded until here
$classesNoLoad = array_merge(get_declared_interfaces(), get_declared_traits(), get_declared_classes());

//execute your app part you want to cache
$app = MyApplication::init();

//find all loaded files until here
$classes = array_merge(get_declared_interfaces(), get_declared_traits(), get_declared_classes());
//remove the classes loaded by composer
$classes = array_diff($classes, $classesNoLoad);

//cache it now
$cache = new SpeedLoader\BuildCache();
$cache->setClasses($classes);
//$cache->setNewLine("\n");
//$cache->setCompressionLevel(SpeedLoader\BuildClass::COMPRESS_HIGH);

file_put_contents('data/cache/classes.php.cache', ' ' . "\n" . $cache->getCachedString());

if (file_exists('data/cache/classes.php.cache')) {
    

// composer autoloading
ways needed, exclude all classes loaded until here
$classesNoLoad = array_merge(get_declared_interfaces(), get_declared_traits(), get_declared_classes());

//execute your app...(only the bootstrap)
$app = Zend\Mvc\Application::init($appConfig);

//find all loaded files
$classes = array_merge(get_declared_interfaces(), get_declared_traits(), get_declared_classes());
$classes = array_diff($classes, $classesNoLoad);

//cache it
$cache = new SpeedLoader\BuildCache();
$cache->setClasses($classes);
//$cache->setNewLine("\n");
//$cache->setCompressionLevel(SpeedLoader\BuildClass::COMPRESS_HIGH);

file_put_contents('data/cache/classes.php.cache', ' ' . "\n" . $cache->getCachedString());

if (file_exists('data/cache/classes.php.cache')) {