Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Speed up - too much (unnecessary) includes #1578
Example: swiftmailer are never need on the frontend, its only to send mails in cronjobs, after sending a post etc., no need to load these 17 files on every page.
Composer already only loads the files it needs. A few causes for this high amount:
As to lowering the amount. Laravel natively supports deferred service providers, causing the provider to be only loaded when any class in the
@gooof Thanks for raising this issue. I will have a look at this for the next beta release after the upcoming beta.8. Out of interest: a) how did you notice this, and b) what did you use to get the list of included files?
Re. service providers: At Laracon, I talked to Taylor about deferred service providers. He agreed they are mostly useless nowadays, and might be removed in a future release. (Memory savings - probably not, CPU cycle savings - meh.) They won't help much with this problem anyway: with well-written service providers, you will only avoid loading the service providers itself. Thanks to the IoC container, services that aren't needed for a request should not be instantiated, and thus not loaded.
What we see here is probably due to two things:
Not very hard to fix, but we'll have to go through all service providers and extensions.
@franzliedke I notice that the API need 0.2sec to load my 3 groups on localhost and that every page has the same response time. While finding out from what the slowness comes, I'll use get_included_files() before the output happens.
A hack is using a own class that call a class only if its really called.
Extensions have a similar problem, in the bootstrap.php should be the event name defined where the class is required.
To add to the
Most Laravel providers (including the mailer) already use singletons that should ideally never resolve if the feature isn't actually used. Right now it's not the case as email drivers are loaded for every request because of the above...