You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: facades.md
+9-9
Original file line number
Diff line number
Diff line change
@@ -10,11 +10,11 @@
10
10
<aname="introduction"></a>
11
11
## Introduction
12
12
13
-
Facades provide a "static" interface to classes that are available in the application's [IoC container](/docs/5.0/container). Laravel ships with many facades, and you have probably been using them without even knowing it! Laravel "facades" serve as "static proxies" to underlying classes in the service container, providing the benefit of a terse, expressive syntax while maintaining more testability and flexibility than traditional static methods.
13
+
Facades provide a "static" interface to classes that are available in the application's [service container](/docs/5.0/container). Laravel ships with many facades, and you have probably been using them without even knowing it! Laravel "facades" serve as "static proxies" to underlying classes in the service container, providing the benefit of a terse, expressive syntax while maintaining more testability and flexibility than traditional static methods.
14
14
15
15
Occasionally, you may wish to create your own facades for your application's and packages, so let's explore the concept, development and usage of these classes.
16
16
17
-
> **Note:** Before digging into facades, it is strongly recommended that you become very familiar with the Laravel [IoC container](/docs/5.0/container).
17
+
> **Note:** Before digging into facades, it is strongly recommended that you become very familiar with the Laravel [service container](/docs/5.0/container).
18
18
19
19
<aname="explanation"></a>
20
20
## Explanation
@@ -23,7 +23,7 @@ In the context of a Laravel application, a facade is a class that provides acces
23
23
24
24
Your facade class only needs to implement a single method: `getFacadeAccessor`. It's the `getFacadeAccessor` method's job to define what to resolve from the container. The `Facade` base class makes use of the `__callStatic()` magic-method to defer calls from your facade to the resolved object.
25
25
26
-
So, when you make a facade call like `Cache::get`, Laravel resolves the Cache manager class out of the IoC container and calls the `get` method on the class. In technical terms, Laravel Facades are a convenient syntax for using the Laravel IoC container as a service locator.
26
+
So, when you make a facade call like `Cache::get`, Laravel resolves the Cache manager class out of the service container and calls the `get` method on the class. In technical terms, Laravel Facades are a convenient syntax for using the Laravel service container as a service locator.
27
27
28
28
<aname="practical-usage"></a>
29
29
## Practical Usage
@@ -45,9 +45,9 @@ However, if we look at that `Illuminate\Support\Facades\Cache` class, you'll see
45
45
46
46
}
47
47
48
-
The Cache class extends the base `Facade` class and defines a method `getFacadeAccessor()`. Remember, this method's job is to return the name of an IoC binding.
48
+
The Cache class extends the base `Facade` class and defines a method `getFacadeAccessor()`. Remember, this method's job is to return the name of a service container binding.
49
49
50
-
When a user references any static method on the `Cache` facade, Laravel resolves the `cache` binding from the IoC container and runs the requested method (in this case, `get`) against that object.
50
+
When a user references any static method on the `Cache` facade, Laravel resolves the `cache` binding from the service container and runs the requested method (in this case, `get`) against that object.
51
51
52
52
So, our `Cache::get` call could be re-written like so:
53
53
@@ -82,7 +82,7 @@ Remember, if you are using a facade in a controller that is namespaced, you will
82
82
83
83
Creating a facade for your own application or package is simple. You only need 3 things:
84
84
85
-
-An IoC binding.
85
+
-A service container binding.
86
86
- A facade class.
87
87
- A facade alias configuration.
88
88
@@ -99,7 +99,7 @@ Let's look at an example. Here, we have a class defined as `PaymentGateway\Payme
99
99
100
100
}
101
101
102
-
We need to be able to resolve this class from the IoC container. So, let's add a binding to a service provider:
102
+
We need to be able to resolve this class from the service container. So, let's add a binding to a service provider:
103
103
104
104
App::bind('payment', function()
105
105
{
@@ -134,9 +134,9 @@ Unit testing is an important aspect of why facades work the way that they do. In
134
134
<aname="facade-class-reference"></a>
135
135
## Facade Class Reference
136
136
137
-
Below you will find every facade and its underlying class. This is a useful tool for quickly digging into the API documentation for a given facade root. The [IoC binding](/docs/5.0/container) key is also included where applicable.
137
+
Below you will find every facade and its underlying class. This is a useful tool for quickly digging into the API documentation for a given facade root. The [service container binding](/docs/5.0/container) key is also included where applicable.
0 commit comments