Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save elfeffe/77a9d3c9fe210dbd71860831c2cc7049 to your computer and use it in GitHub Desktop.
Save elfeffe/77a9d3c9fe210dbd71860831c2cc7049 to your computer and use it in GitHub Desktop.
Replace Magento autoloader with composer based autoloader. Note: you are losing the ability to use the compiler.
<?php
/**
* Classes source autoload
*/
class Varien_Autoload
{
/** @var \Composer\Autoload\ClassLoader */
private static $autoloader;
/** @var self */
private static $instance;
/**
* Singleton pattern implementation
*
* @return Varien_Autoload
*/
static public function instance()
{
if (!self::$instance) {
self::$instance = new Varien_Autoload();
}
return self::$instance;
}
/**
* Register composer autoloader
*/
static public function register()
{
if (!static::$autoloader) {
static::$autoloader = require __DIR__ . '/../../../../vendor/autoload.php';
}
}
/**
* Load class source code
*
* @param string $class
* @return bool
*/
public function autoload($class)
{
return static::$autoloader->loadClass($class);
}
public function registerScope($scope)
{}
public static function getScope()
{}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment