Support the ongoing development of Laravel.io →
posted 10 years ago
Configuration
Last updated 2 years ago.
0

I have been asking myself this exact question and would be curious to hear what you find out @niteshn

My autoload_classmap.php is also 3,200+ lines and I have been having performance concerns on my production server. It would be great to hear what resources/answers you come across.

Last updated 2 years ago.
0

Loading a single file once is better then a whole bunch of look-ups every single time. That's why when you run artisan optimize it also optimizes the autoloader by compiling all the PSR-0/4 into classmaps. If it didn't whenever you instantiate a new class the autoloader would need to lookup and require that file.

So to answer your questions.

  1. PSR-0 (new projects should start using PSR-4, it's tidier).
  2. It's not an issue. The compiled file will probably be at least 3 or 4 times the size of the classmap file. Like I said above, a single require is better than a few dozen.
Last updated 2 years ago.
0

3000 lines? wut. I wish my applications were only 3000 lines.

Learn to optimize real things. Your fastest query is slower than PHP running a freaking SINGLE file.

Last updated 2 years ago.
0

Classmaps will always be faster than psr-0 / psr-4.

The only possible issue could be memory as the entire classmap is stored in one big array. However unless you have a truly ridiculous amount of classes I doubt this would be an issue.

A bit of testing using the previously mentioned zend framework libraries.

Using zend framework 1.12.7: There were 2450 classes. These took up somewhere around 700k.

Even a large application is unlikely to have more than 1-2MB array for the classmap. I don't think it is work worrying about.

If you really want to optimize things that don't matter much what you want to do is separate classes by how often they are needed.

Group 1 would be things that are needed basically every request. These can be concatenated and included on every request.

Group 2 would be frequently used classes. These can be added to the classmap.

Group 3 would be classes that are hardly ever used. They can be loaded with psr-0 / psr-4

Again this would be a lot of work for very little benefit but if you feel like it then go ahead.

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

niteshn niteshn Joined 20 Feb 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.