composer/composer — pull request #1857 by superdweebie (2013-05-03 02:15:33+00:00)
Title: Modify classmap

This pr does two things:

* It modifies the `ClassLoader` so that it keeps record of changes to it's `classmap` and can report if the classmap has been modified.

* It extends `autoload_real` and adds a new file generated by `autoload-dump` called `persist_modified_classmap`. Including this new file will persist any classmap changes to file ready for the next time the loader is used (eg next request).

Why? The optimize flag for `autoload-dump` is good, but when using a framework such as zf2 or symfony, the dumped classmap can easily have 3000+ items. Most of these are not used, it is very rare for an app to use _all_ of a framework. This http://patrickallaert.blogspot.com.au/2013/03/benchmarking-composer-autoloading.html showed that loading a huge classmap can actually be a hindrance to performance. This pr allows the classmap to grow dynamically to only include those classes that are actually used by an app.

Usage psuedo code:

//set up the loader
require('vendor/autoload.php);

//do stuff...
My\Application::run();

//persist any changes to classmap
require('vendor/persist_modified_classmap.php');

In my own testing on a zf2 app with doctrine, this is clearly faster than using the `optimize` flag.