Issue
Can you help me to find the difference between composer install and composer install -o.
Normally composer install -o generate an optimized autoloder file, but when i generates it it was like the other file with composer install.
my classmapfile have many path but the result of composer install -o and composer install steel the same can you explain this for me ? can you help me ?
Solution
You are on the right track: The -o
option creates an "optimized" autoloader that essentially is a classmap for every class that otherwise would be loaded through PSR-0 or PSR-4. Composer will scan all directories that are mentioned for PSR-0 and PSR-4 just like it would always to with classmap
entries.
This might already answer your question: If your project only has a classmap
entry and nothing else, there is no difference in the result.
Note that it is not the best idea to prematurely optimize the autoloading by forcing the classmap
if you could also use one of the PSR schemes. Using only the classmap will hinder development because every time a new class is created, you'd have to dump the autoloader with that new entry. Also note that creating huge classmaps might actually be slower than PSR-based class loading, because you trade code execution time for allocated memory, and at some point allocating memory for all classes in every request even if they are not being used will be slower than executing PSR autoloading. You'd have to measure your individual application performance with both a normal and an optimized autoloader to decide which one is actually better.
More info in the docs
Answered By - Sven
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.