Skip to content

Instantly share code, notes, and snippets.

@Seldaek Seldaek/foo.php
Created Sep 30, 2016

Embed
What would you like to do?
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
You can’t perform that action at this time.