PHPackages                             thadafinser/speed-loader - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. thadafinser/speed-loader

AbandonedLibrary[Utility &amp; Helpers](/categories/utility)

thadafinser/speed-loader
========================

Load classes faster

v1.0.0(11y ago)163MITPHPPHP &gt;=5.5

Since Apr 13Pushed 10y ago1 watchersCompare

[ Source](https://github.com/ThaDafinser/SpeedLoader)[ Packagist](https://packagist.org/packages/thadafinser/speed-loader)[ Docs](https://github.com/ThaDafinser/SpeedLoader)[ RSS](/packages/thadafinser-speed-loader/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (3)Versions (2)Used By (0)

SpeedLoader - load only one file
================================

[](#speedloader---load-only-one-file)

[![Build Status](https://camo.githubusercontent.com/3e9053c437d14eb2931b3d3af7ac6caff622eb36e3951b6fd8439103810606bd/68747470733a2f2f7472617669732d63692e6f72672f546861446166696e7365722f53706565644c6f616465722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/ThaDafinser/SpeedLoader)[![Code Coverage](https://camo.githubusercontent.com/22305efae18cdd6d51081a96a6bb47a33f58caa1d302ce96b0abd3f43bed80c6/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f546861446166696e7365722f53706565644c6f616465722f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/ThaDafinser/SpeedLoader/?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/1d38a696f3316c0ed095d21370d7ab75462e2f3e4ccd026a014f3c9d3d7b87a4/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f546861446166696e7365722f53706565644c6f616465722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/ThaDafinser/SpeedLoader/?branch=master)

One file to load all your needed classes at once! Since autoloading takes more and more time, it has become very important to have an efficient autoloading. `SpeedLoader` aims to improve your autoloading experience

Install
-------

[](#install)

Get it with composer:

```
composer require thadafinser/speed-loader

```

### Create a seperate file

[](#create-a-seperate-file)

```
// composer autoloading
require 'vendor/autoload.php';

//since composer is always 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', '
