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.
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.
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.
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.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community