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: artisan.md
+8-8
Original file line number
Diff line number
Diff line change
@@ -11,26 +11,26 @@ Artisan is the name of the command-line interface included with Laravel. It prov
11
11
<aname="usage"></a>
12
12
## Usage
13
13
14
-
To view a list of all available Artisan commands, you may use the `list` command:
15
-
16
14
#### Listing All Available Commands
17
15
18
-
php artisan list
16
+
To view a list of all available Artisan commands, you may use the `list` command:
19
17
20
-
Every command also includes a "help" screen which displays and describes the command's available arguments and options. To view a help screen, simply precede the name of the command with `help`:
18
+
php artisan list
21
19
22
20
#### Viewing The Help Screen For A Command
23
21
24
-
php artisan help migrate
22
+
Every command also includes a "help" screen which displays and describes the command's available arguments and options. To view a help screen, simply precede the name of the command with `help`:
25
23
26
-
You may specify the configuration environment that should be used while running a command using the `--env` switch:
24
+
php artisan help migrate
27
25
28
26
#### Specifying The Configuration Environment
29
27
30
-
php artisan migrate --env=local
28
+
You may specify the configuration environment that should be used while running a command using the `--env` switch:
31
29
32
-
You may also view the current version of your Laravel installation using the `--version` option:
30
+
php artisan migrate --env=local
33
31
34
32
#### Displaying Your Current Laravel Version
35
33
34
+
You may also view the current version of your Laravel installation using the `--version` option:
Copy file name to clipboardExpand all lines: cache.md
+4-4
Original file line number
Diff line number
Diff line change
@@ -95,17 +95,17 @@ All drivers except `file` and `database` support the `increment` and `decrement`
95
95
96
96
> **Note:** Cache tags are not supported when using the `file` or `database` cache drivers. Furthermore, when using multiple tags with caches that are stored "forever", performance will be best with a driver such as `memcached`, which automatically purges stale records.
97
97
98
-
Cache tags allow you to tag related items in the cache, and then flush all caches tagged with a given name. To access a tagged cache, use the `tags` method:
99
-
100
98
#### Accessing A Tagged Cache
101
99
102
-
You may store a tagged cache by passing in an ordered list of tag names as arguments, or as an ordered array of tag names.
100
+
Cache tags allow you to tag related items in the cache, and then flush all caches tagged with a given name. To access a tagged cache, use the `tags` method.
101
+
102
+
You may store a tagged cache by passing in an ordered list of tag names as arguments, or as an ordered array of tag names:
You may use any cache storage method in combination with tags, including `remember`, `forever`, and `rememberForever`. You may also access cached items from the tagged cache, as well as use the other cache methods such as `increment` and `decrement`:
108
+
You may use any cache storage method in combination with tags, including `remember`, `forever`, and `rememberForever`. You may also access cached items from the tagged cache, as well as use the other cache methods such as `increment` and `decrement`.
Copy file name to clipboardExpand all lines: commands.md
+4-6
Original file line number
Diff line number
Diff line change
@@ -117,23 +117,21 @@ You may also specify a default value to the `confirm` method, which should be `t
117
117
<aname="registering-commands"></a>
118
118
## Registering Commands
119
119
120
-
Once your command is finished, you need to register it with Artisan so it will be available for use. This is typically done in the `app/start/artisan.php` file. Within this file, you may use the `Artisan::add` method to register the command:
121
-
122
120
#### Registering An Artisan Command
123
121
124
-
Artisan::add(new CustomCommand);
122
+
Once your command is finished, you need to register it with Artisan so it will be available for use. This is typically done in the `app/start/artisan.php` file. Within this file, you may use the `Artisan::add` method to register the command:
125
123
126
-
If your command is registered in the application [IoC container](/docs/ioc), you may use the `Artisan::resolve` method to make it available to Artisan:
124
+
Artisan::add(new CustomCommand);
127
125
128
126
#### Registering A Command That Is In The IoC Container
129
127
128
+
If your command is registered in the application [IoC container](/docs/ioc), you may use the `Artisan::resolve` method to make it available to Artisan:
129
+
130
130
Artisan::resolve('binding.name');
131
131
132
132
<aname="calling-other-commands"></a>
133
133
## Calling Other Commands
134
134
135
135
Sometimes you may wish to call other commands from your command. You may do so using the `call` method:
Copy file name to clipboardExpand all lines: controllers.md
-2
Original file line number
Diff line number
Diff line change
@@ -125,8 +125,6 @@ If you would like to use another method on the controller as a filter, you may u
125
125
126
126
Laravel allows you to easily define a single route to handle every action in a controller using simple, REST naming conventions. First, define the route using the `Route::controller` method:
127
127
128
-
#### Defining A RESTful Controller
129
-
130
128
Route::controller('users', 'UserController');
131
129
132
130
The `controller` method accepts two arguments. The first is the base URI the controller handles, while the second is the class name of the controller. Next, just add methods to your controller, prefixed with the HTTP verb they respond to:
Copy file name to clipboardExpand all lines: events.md
+16-16
Original file line number
Diff line number
Diff line change
@@ -24,18 +24,18 @@ The Laravel `Event` class provides a simple observer implementation, allowing yo
24
24
25
25
$event = Event::fire('auth.login', array($user));
26
26
27
-
You may also specify a priority when subscribing to events. Listeners with higher priority will be run first, while listeners that have the same priority will be run in order of subscription.
28
-
29
27
#### Subscribing To Events With Priority
30
28
29
+
You may also specify a priority when subscribing to events. Listeners with higher priority will be run first, while listeners that have the same priority will be run in order of subscription.
30
+
31
31
Event::listen('auth.login', 'LoginHandler', 10);
32
32
33
33
Event::listen('auth.login', 'OtherHandler', 5);
34
34
35
-
Sometimes, you may wish to stop the propagation of an event to other listeners. You may do so using by returning `false` from your listener:
36
-
37
35
#### Stopping The Propagation Of An Event
38
36
37
+
Sometimes, you may wish to stop the propagation of an event to other listeners. You may do so using by returning `false` from your listener:
38
+
39
39
Event::listen('auth.login', function($event)
40
40
{
41
41
// Handle the event...
@@ -52,10 +52,10 @@ If your `start` files are getting too crowded, you could create a separate `app/
52
52
<aname="wildcard-listeners"></a>
53
53
## Wildcard Listeners
54
54
55
-
When registering an event listener, you may use asterisks to specify wildcard listeners:
56
-
57
55
#### Registering Wildcard Event Listeners
58
56
57
+
When registering an event listener, you may use asterisks to specify wildcard listeners:
58
+
59
59
Event::listen('foo.*', function($param)
60
60
{
61
61
// Handle the event...
@@ -82,10 +82,10 @@ In some cases, you may wish to use a class to handle an event rather than a Clos
82
82
83
83
Event::listen('auth.login', 'LoginHandler');
84
84
85
-
By default, the `handle` method on the `LoginHandler` class will be called:
86
-
87
85
#### Defining An Event Listener Class
88
86
87
+
By default, the `handle` method on the `LoginHandler` class will be called:
88
+
89
89
class LoginHandler {
90
90
91
91
public function handle($data)
@@ -95,19 +95,19 @@ By default, the `handle` method on the `LoginHandler` class will be called:
95
95
96
96
}
97
97
98
-
If you do not wish to use the default `handle` method, you may specify the method that should be subscribed:
99
-
100
98
#### Specifying Which Method To Subscribe
101
99
100
+
If you do not wish to use the default `handle` method, you may specify the method that should be subscribed:
Using the `queue` and `flush` methods, you may "queue" an event for firing, but not fire it immediately:
108
-
109
107
#### Registering A Queued Event
110
108
109
+
Using the `queue` and `flush` methods, you may "queue" an event for firing, but not fire it immediately:
110
+
111
111
Event::queue('foo', array($user));
112
112
113
113
#### Registering An Event Flusher
@@ -124,10 +124,10 @@ Finally, you may run the "flusher" and flush all queued events using the `flush`
124
124
<aname="event-subscribers"></a>
125
125
## Event Subscribers
126
126
127
-
Event subscribers are classes that may subscribe to multiple events from within the class itself. Subscribers should define a `subscribe` method, which will be passed an event dispatcher instance:
128
-
129
127
#### Defining An Event Subscriber
130
128
129
+
Event subscribers are classes that may subscribe to multiple events from within the class itself. Subscribers should define a `subscribe` method, which will be passed an event dispatcher instance:
130
+
131
131
class UserEventHandler {
132
132
133
133
/**
@@ -161,10 +161,10 @@ Event subscribers are classes that may subscribe to multiple events from within
161
161
162
162
}
163
163
164
-
Once the subscriber has been defined, it may be registered with the `Event` class.
165
-
166
164
#### Registering An Event Subscriber
167
165
166
+
Once the subscriber has been defined, it may be registered with the `Event` class.
Copy file name to clipboardExpand all lines: html.md
+6-6
Original file line number
Diff line number
Diff line change
@@ -46,10 +46,10 @@ If your form is going to accept file uploads, add a `files` option to your array
46
46
<aname="csrf-protection"></a>
47
47
## CSRF Protection
48
48
49
-
Laravel provides an easy method of protecting your application from cross-site request forgeries. First, a random token is placed in your user's session. Don't sweat it, this is done automatically. The CSRF token will be added to your forms as a hidden field automatically. However, if you wish to generate the HTML for the hidden field, you may use the `token` method:
50
-
51
49
#### Adding The CSRF Token To A Form
52
50
51
+
Laravel provides an easy method of protecting your application from cross-site request forgeries. First, a random token is placed in your user's session. Don't sweat it, this is done automatically. The CSRF token will be added to your forms as a hidden field automatically. However, if you wish to generate the HTML for the hidden field, you may use the `token` method:
52
+
53
53
echo Form::token();
54
54
55
55
#### Attaching The CSRF Filter To A Route
@@ -62,10 +62,10 @@ Laravel provides an easy method of protecting your application from cross-site r
62
62
<aname="form-model-binding"></a>
63
63
## Form Model Binding
64
64
65
-
Often, you will want to populate a form based on the contents of a model. To do so, use the `Form::model` method:
66
-
67
65
#### Opening A Model Form
68
66
67
+
Often, you will want to populate a form based on the contents of a model. To do so, use the `Form::model` method:
Now, when you generate a form element, like a text input, the model's value matching the field's name will automatically be set as the field value. So, for example, for a text input named `email`, the user model's `email` attribute would be set as the value. However, there's more! If there is an item in the Session flash data matching the input name, that will take precedence over the model's value. So, the priority looks like this:
@@ -175,10 +175,10 @@ This allows you to quickly build forms that not only bind to model values, but e
175
175
<aname="custom-macros"></a>
176
176
## Custom Macros
177
177
178
-
It's easy to define your own custom Form class helpers called "macros". Here's how it works. First, simply register the macro with a given name and a Closure:
179
-
180
178
#### Registering A Form Macro
181
179
180
+
It's easy to define your own custom Form class helpers called "macros". Here's how it works. First, simply register the macro with a given name and a Closure:
Copy file name to clipboardExpand all lines: ioc.md
+18-18
Original file line number
Diff line number
Diff line change
@@ -18,10 +18,10 @@ Understanding the Laravel IoC container is essential to building a powerful, lar
18
18
<aname="basic-usage"></a>
19
19
## Basic Usage
20
20
21
-
There are two ways the IoC container can resolve dependencies: via Closure callbacks or automatic resolution. First, we'll explore Closure callbacks. First, a "type" may be bound into the container:
22
-
23
21
#### Binding A Type Into The Container
24
22
23
+
There are two ways the IoC container can resolve dependencies: via Closure callbacks or automatic resolution. First, we'll explore Closure callbacks. First, a "type" may be bound into the container:
24
+
25
25
App::bind('foo', function($app)
26
26
{
27
27
return new FooBar;
@@ -33,19 +33,19 @@ There are two ways the IoC container can resolve dependencies: via Closure callb
33
33
34
34
When the `App::make` method is called, the Closure callback is executed and the result is returned.
35
35
36
-
Sometimes, you may wish to bind something into the container that should only be resolved once, and the same instance should be returned on subsequent calls into the container:
37
-
38
36
#### Binding A "Shared" Type Into The Container
39
37
38
+
Sometimes, you may wish to bind something into the container that should only be resolved once, and the same instance should be returned on subsequent calls into the container:
39
+
40
40
App::singleton('foo', function()
41
41
{
42
42
return new FooBar;
43
43
});
44
44
45
-
You may also bind an existing object instance into the container using the `instance` method:
46
-
47
45
#### Binding An Existing Instance Into The Container
48
46
47
+
You may also bind an existing object instance into the container using the `instance` method:
48
+
49
49
$foo = new Foo;
50
50
51
51
App::instance('foo', $foo);
@@ -60,10 +60,10 @@ If your application has a very large number of IoC bindings, or you simply wish
60
60
<aname="automatic-resolution"></a>
61
61
## Automatic Resolution
62
62
63
-
The IoC container is powerful enough to resolve classes without any configuration at all in many scenarios. For example:
64
-
65
63
#### Resolving A Class
66
64
65
+
The IoC container is powerful enough to resolve classes without any configuration at all in many scenarios. For example:
66
+
67
67
class FooBar {
68
68
69
69
public function __construct(Baz $baz)
@@ -79,10 +79,10 @@ Note that even though we did not register the FooBar class in the container, the
79
79
80
80
When a type is not bound in the container, it will use PHP's Reflection facilities to inspect the class and read the constructor's type-hints. Using this information, the container can automatically build an instance of the class.
81
81
82
-
However, in some cases, a class may depend on an interface implementation, not a "concrete type". When this is the case, the `App::bind` method must be used to inform the container which interface implementation to inject:
83
-
84
82
#### Binding An Interface To An Implementation
85
83
84
+
However, in some cases, a class may depend on an interface implementation, not a "concrete type". When this is the case, the `App::bind` method must be used to inform the container which interface implementation to inject:
@@ -123,10 +123,10 @@ Laravel provides several opportunities to use the IoC container to increase the
123
123
124
124
In this example, the `OrderRepository` class will automatically be injected into the controller. This means that when [unit testing](/docs/testing) a "mock" `OrderRepository` may be bound into the container and injected into the controller, allowing for painless stubbing of database layer interaction.
125
125
126
-
[Filters](/docs/routing#route-filters), [composers](/docs/responses#view-composers), and [event handlers](/docs/events#using-classes-as-listeners) may also be resolved out of the IoC container. When registering them, simply give the name of the class that should be used:
127
-
128
126
#### Other Examples Of IoC Usage
129
127
128
+
[Filters](/docs/routing#route-filters), [composers](/docs/responses#view-composers), and [event handlers](/docs/events#using-classes-as-listeners) may also be resolved out of the IoC container. When registering them, simply give the name of the class that should be used:
129
+
130
130
Route::filter('foo', 'FooFilter');
131
131
132
132
View::composer('foo', 'FooComposer');
@@ -140,10 +140,10 @@ Service providers are a great way to group related IoC registrations in a single
140
140
141
141
In fact, most of the core Laravel components include service providers. All of the registered service providers for your application are listed in the `providers` array of the `app/config/app.php` configuration file.
142
142
143
-
To create a service provider, simply extend the `Illuminate\Support\ServiceProvider` class and define a `register` method:
144
-
145
143
#### Defining A Service Provider
146
144
145
+
To create a service provider, simply extend the `Illuminate\Support\ServiceProvider` class and define a `register` method:
146
+
147
147
use Illuminate\Support\ServiceProvider;
148
148
149
149
class FooServiceProvider extends ServiceProvider {
@@ -160,19 +160,19 @@ To create a service provider, simply extend the `Illuminate\Support\ServiceProvi
160
160
161
161
Note that in the `register` method, the application IoC container is available to you via the `$this->app` property. Once you have created a provider and are ready to register it with your application, simply add it to the `providers` array in your `app` configuration file.
162
162
163
-
You may also register a service provider at run-time using the `App::register` method:
164
-
165
163
#### Registering A Service Provider At Run-Time
166
164
165
+
You may also register a service provider at run-time using the `App::register` method:
166
+
167
167
App::register('FooServiceProvider');
168
168
169
169
<aname="container-events"></a>
170
170
## Container Events
171
171
172
-
The container fires an event each time it resolves an object. You may listen to this event using the `resolving` method:
173
-
174
172
#### Registering A Resolving Listener
175
173
174
+
The container fires an event each time it resolves an object. You may listen to this event using the `resolving` method:
0 commit comments