Skip to content
This repository has been archived by the owner on Aug 12, 2019. It is now read-only.

nextras/composer-autoload-simplifier

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Nextras Composer Autoload Simplifier

Downloads this Month Stable version

Nextras Composer Autoload Simplifier is a Composer plugin which can replace vendor/autoload.php with a simplified and therefore slightly faster version.

Installation

Use composer:

$ composer require nextras/composer-autoload-simplifier

Example of Simplified Autoloader

<?php declare(strict_types = 1);

(function () {
	$requireClassScoped = function (string $path) {
		require $path;
	};

	$requireFileScoped = function (string $id, string $path) {
		if (empty($GLOBALS['__composer_autoload_files'][$id])) {
			require $path;
			$GLOBALS['__composer_autoload_files'][$id] = TRUE;
		}
	};

	spl_autoload_register(function (string $className) use ($requireClassScoped) {
		static $classMap = [
			'Tracy\\Bar' => __DIR__ . '/tracy/tracy/src/Tracy/Bar.php',
			'Tracy\\BlueScreen' => __DIR__ . '/tracy/tracy/src/Tracy/BlueScreen.php',
            ...
		];

		if (isset($classMap[$className])) {
			$requireClassScoped($classMap[$className]);
		}
	});

	$requireFileScoped('7745382c92b7799bf1294b1f43023ba2', __DIR__ . '/tracy/tracy/src/shortcuts.php');
})();

License

MIT. See full license.

About

Simplifies autoloader generated by Composer

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages