Skip to content

Instantly share code, notes, and snippets.

@Seldaek
Created September 30, 2016 08:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Seldaek/f0be6a5267b56ed3ebbb410c1c826cec to your computer and use it in GitHub Desktop.
Save Seldaek/f0be6a5267b56ed3ebbb410c1c826cec to your computer and use it in GitHub Desktop.
Case-insensitive Classmap
// in POST_AUTOLOAD_DUMP
$map = include('autoload_classmap.php');
// TODO lowercase all keys
file_put_contents('autoload_classmap.php', '<?php return '.var_export($map, 1));
// the above should be done without include ideally to keep the classmap using relative paths,
// but if you don't move the project files around then this is fine.
// at RUNTIME
$loader = require 'vendor/autoload.php';
$loader->unregister();
spl_autoload_register(function ($class) use ($loader) {
$loader->loadClass(strtolower($class));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment