Reputation: 31
I don't quite understand why should I use facades in Laravel. Why don't just create simple class with static methods instead? I mean, these methods I can call from almost any place in my code just like using Facades. That way I don't need to create facade, add it to autoload section in composer.json or bind it in ServiceProvider. What I see is the same result using both options, but using facades is much more complicated way to me.
Upvotes: 3
Views: 146
Reputation: 10176
They are described in details here.
From my experience, the biggest benefit of a Facade is the ability to mock or stub the methods it contains, which is not possibile (or at least is very hard) to do with a purely static class.
So, basically, Facades are easier to test.
Upvotes: 3