Guilhem Soulas
Guilhem Soulas

Reputation: 1995

Zend Framework 2: Autoload classmap

I generated the classmap of our project to improve its performance in production.

I'm surprised because the generated file is really big (more than 5000 lines). It includes the whole ZF2 library, Doctrine, etc.

Is it normal or should I exclude the vendor directory?


EDIT:

@Sam, yes we are using APC in production.

My plan is to automatically generate the class map as part of the deployment process.

Upvotes: 0

Views: 1148

Answers (1)

Sam
Sam

Reputation: 16445

I suppose you're talking about the classmap autoloader provided by composer? Then yes, this is absolutely normal. The classmap generated for each module should only contain the modules classes tho.

As far as performance is concerned, that's a bit of a tricky thing. If you do not have access to APC or Memcache (or any other memory cache for that matter), then a 5000 Lines classmap loader will probably not be the most ideal solution.

The most ideal solution would be a classmap that ONLY contains the autoloading directives for the classes that you actually use throughout your project. Luckily Evan ".pro" Coury has created the very great EdpSuperluminal. That one does precisely what the ideal solution is all about, but it requires quite a bit of manual attention, since basically once your project is done you'll need to call every single URL of your application once with a special URL parameter to create the classmap.

Upvotes: 5

Related Questions