Classmap Autoloading
Classmap autoloading scans directories for class definitions and builds a static map — useful for legacy code without PSR-4 namespaces.
Classmap autoloading scans directories for class definitions and builds a static map — useful for legacy code without PSR-4 namespaces.
"autoload": {
"psr-4": { "App\\": "src/" },
"classmap": ["lib/", "legacy/"],
"files": ["src/helpers.php", "src/functions.php"]
}
# Optimised classmap (for production — faster than PSR-4 lookup)
composer dump-autoload --optimize
# Or combined with install
composer install --optimize-autoloader
The files array is loaded on every request — keep it small and only for global helper functions.