Skip to content

Instantly share code, notes, and snippets.

@AndrewCarterUK
Last active February 12, 2016 16:01
Show Gist options
  • Save AndrewCarterUK/ecb36fd7ba995f7697a8 to your computer and use it in GitHub Desktop.
Save AndrewCarterUK/ecb36fd7ba995f7697a8 to your computer and use it in GitHub Desktop.
Class "preloading" with Composer
<?php
/*
This should work because composer registers a callback using
'spl_autoload_register' for when a class is used that has not
already been loaded. Loading the class before hand will
prevent that callback being triggered by PHP.
*/
/** @var Composer\Autoload\ClassLoader **/
$classLoader = include 'vendor/autoload.php';
$classLoader->loadClass('Path\\To\\MyClass');
$classLoader->loadClass('Path\\To\\OtherClass');
// ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment