PSR-4 resolves a class by turning its namespace into a path, which requires the code to have namespaces and for the directory layout to agree with them. A tree of five-year-old library files named Product_Importer and Csv_Reader has neither, and rewriting them is not this week’s work. Composer’s classmap is the entry for exactly that directory.
{
"autoload": {
"psr-4": { "App\": "src/" },
"classmap": [ "legacy/libraries/", "legacy/models/" ]
}
}
Composer scans the listed directories once, records every class, interface and trait it finds against its file, and writes a flat array. Lookups are then a single array read with no filesystem access at all, which makes a classmap the fastest of the three strategies — and its cost is that the map is built at install and dump-autoload time, so a newly added file is invisible until you rebuild it. That is fine for a directory nobody adds to, which is the whole point of putting the legacy tree here and the new code under PSR-4. The two blocks coexist; classes move from one to the other one at a time.