The problem with the advent of Laravel and its popularity, is that it teaches wrong ideas to a huge amount of people.
Laravel facades are not facades. They definetely misuse the term.
What Laravel calls facade is just an opaque PHP magic method wrapper.
Learning programming "design patterns" is quite difficult, and this kind of framework is a danger from ths perspective.
So please take 2 minutes to learn the real facade design pattern: design_patterns/facade or here proxy-pattern.
Laravel facades are not facades. They definetely misuse the term.
What Laravel calls facade is just an opaque PHP magic method wrapper.
Said differently they're static proxies to service locators.
A proxy should be called a proxy, it is a pattern used elsewhere like in Java (RMI), Corba, etc.
A proxy should be called a proxy, it is a pattern used elsewhere like in Java (RMI), Corba, etc.
You should also read about "dynamic proxy".
How are they different?
A facade hides something that takes a complex, multi-step operation, and simplifies it. So the interface (=public methods) is different: it is simplified, and 1 method call replaces several calls to one or many objects.
A proxy on the other hand has the exact same interface (meaning same list of public methods) of 1 proxied object, and usually add a feature (in example like logging method calls or usage of a network call).
(for some it could be confused with Decorator).
(for some it could be confused with Decorator).
So please take 2 minutes to learn the real facade design pattern: design_patterns/facade or here proxy-pattern.
I am glad some people know design patterns (@pmjones): I could not resist to add my word to this discussion: about laravel facade.
Finally as I said there, maybe it is PHP magic methods are just plain evil for OO design.