Better Dependency Injection in Laravel
We all love using Dependency Injection but often Laravel’s facades and IoC container are used more like a static service locator, which (despite being testable) can easily lead to violations of the Dependency Inversion Principle (the D in SOLID).
There’s been a lot of discussion around this in the PHP community recently, with calls to stop using facades as well as how service locators can be used safely (the comments here are good too).
The great news is Taylor, the main author of Laravel, has responded to this and made a change to Laravel in v4.1.15 that makes it much easier to inject dependencies directly into controllers.
I’m happy to see constructive criticism actually influencing and benefiting a framework so positively. Hopefully we’ll see more if this in the PHP community!