Replies: 1 comment 14 replies
-
I cannot claim to be an expert about Composer autoload, however it does seem to me that it is not a great idea to autoload masses of files on every single boot, when many of the files loaded may never be called. In a small Laravel application, loading everything might not be a problem, but in a very large application there might be some definite performance overheads for loading unnecessary files. IMO it would be better for each package to register its own single autoload boot file. Each package can then create an intelligent load strategy that loads the minimal files on actual boot, and then loads additional files when they turn out to be needed. You could even have a default strategy to load every PHP file in So for example, a boot to run a command-line call would only need to autoload files needed for the command that is called. Or files used for a particular route could be loaded by middleware depending on the URL route etc. Composer could provide some callable methods to e.g. load all php files in a specified path-mask e.g. P.S. I guess that it is not strictly necessary for Composer to change - it is up to each package to define what files are autoloaded by Composer, so I guess that Laravel could create its own bootstrap autoload functionality without any changes to Composer. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
With increasing packages and builtin commands (like searching for commands / events) that searching for files in app directory (for registering its own "map", reading files, etc) it would be great to introduce a way how packages can register its own patterns (or matching logic) and a closure / handle class (with dependency injection in class).
Is this what Laravel would support? I can make the contribution.
Thanks for the info,
Martin
Beta Was this translation helpful? Give feedback.
All reactions