L
L
lead worker2015-05-15 23:07:11
Design patterns
lead worker, 2015-05-15 23:07:11

Am I understanding facade in Laravel correctly?

I'm tinkering with Laravel and the implementation of the facade in the Illuminate\Support\Facades format is not entirely clear to me.
In my mind, the Facade pattern is a single point of access to a coherent package that consists of several classes (or any other coherent structure consisting of parts). That is, instead of operating on the internal classes of the package, we operate on a facade that translates the desired functionality from the required classes or classes of the package. Thus, package encapsulation is achieved, and unnecessary dependencies are avoided.
In the Laravel format, as far as I understand, the facade is essentially a wrapper that gives more convenient access to the class. Or rather, not even to the class, but to its alias in IoC. That is, it allows you to compress the class call syntax, but has little to do with my idea of ​​\u200b\u200ba facade.
Did I not have a correct understanding of the Facade pattern, or did I not correctly understand its implementation in Laravel?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
J
JhaoDa, 2015-05-15
@JhaoDa

Yes, in Laravel it's just a wrapper for an alias in a container.

S
Sergey, 2015-05-15
Protko @Fesor

Well, in a more simplified form, the term "facade" is understood as "a simpler interface that hides the complexity of implementation." That is, a static method, instead of referring to IoC, seems to fit the description, but somehow poorly, yes.
It seems like in the 5th Laravel you can already do without this Satan with static.

E
Evgeny Elchev, 2015-08-06
@rsi

You correctly described everything, in the chest the facade is not an implementation of the facade pattern.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question