[Forwardport] Add generated code to the psr-0 autoloader section so when optimizing… #17056
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Original Pull Request
#16435
… the autoloader on a production environment the autoloader will find more classes in its classmap. This should result in fewer file_exists calls and might increase the performance a tiny bit.
As @orlangur requested, this is a backport of #15438 for Magento 2.2
Description
Hi!
This PR was triggered by some discussions over here: davidalger/capistrano-magento2#102
When you read the Magento documentation around performance best practices for deploying to a production environment, you'll see something like this:
Since the docs mention you should dump the autoloader after certain php classes got autogenerated, you would assume that the autoloader classmap file (
vendor/composer/autoload_classmap.php
) should have a mapping of those generated classes.But that isn't the case right now.
This PR fixes this.
This should - in theory - increase the autoloading performance ever so slightly on production environments, since the autoloader wouldn't have to go searching for files on the filesystem but would already find them in the classmap and wouldn't have to perform
file_exists
calls for those generated classes.Watch out:
vendor/composer/ClassLoader.php
file and some research on the world wide web."psr-4"
or the"psr-0"
or the"classmap"
section of the"autoload"
section in thecomposer.json
file. It was already suggested to put it in theclassmap
section over here: Improve performances by improving composer autoload #9102 but I'm not sure after reading the composer documentation? It seems to work in all 3 sections while testing, but I've decided to put it in the already being used"psr-0"
section for now.magento/project-community-edition
of which the sources I can't seem to find on github (unless thecomposer.json
file which comes with it is somehow build using thecomposer.json
file of this project?)composer.json
file of already existing projects doesn't get updated automatically after upgrading to a newer version of Magento.var/generation/
Fixed Issues (if relevant)
None that I could find
Manual testing scenarios
bin/magento setup:di:compile
composer dump-autoload -o
vendor/composer/autoload_classmap.php
and see if you can find a mapping to a file insidegenerated/code
, you won't find anycomposer.json
as in this PRcomposer dump-autoload -o
vendor/composer/autoload_classmap.php
and see if you can find a mapping to a file insidegenerated/code
, you will find some referencesContribution checklist