Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

includes PhpSpreadsheet autoload no-composer #4171

Open
testAccountDeltas opened this issue Sep 25, 2024 · 0 comments
Open

includes PhpSpreadsheet autoload no-composer #4171

testAccountDeltas opened this issue Sep 25, 2024 · 0 comments

Comments

@testAccountDeltas
Copy link

testAccountDeltas commented Sep 25, 2024

Hello

https://gist.github.com/testAccountDeltas/f9985005363f53e6294c49324fdd0fe7

<?
foreach([
	'Psr\\SimpleCache\\' => '/simple-cache/',
	'PhpOffice\\PhpSpreadsheet\\' => '/PhpSpreadsheet/',
	'ZipStream' => '/ZipStream/',
	'MyCLabs\\Enum' => '/enum/',
] as $prefix => $baseDir) {
	spl_autoload_register(function ($class) use ($prefix, $baseDir) {
		$baseDir = __DIR__ . $baseDir;
		
		$len = strlen($prefix);
		if (strncmp($prefix, $class, $len) !== 0) {
			return;
		}

		$relativeClass = substr($class, $len);
		$file = $baseDir . str_replace('\\', '/', $relativeClass) . '.php';

		if (file_exists($file)) {
			require $file;
		}
	});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant