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
-[Calling Commands From Other Commands](#calling-commands-from-other-commands)
21
+
-[Signal Handling](#signal-handling)
21
22
-[Stub Customization](#stub-customization)
22
23
-[Events](#events)
23
24
@@ -274,6 +275,10 @@ When calling this method, the `user` arguments may be passed in order to the com
274
275
275
276
php artisan mail:send foo bar
276
277
278
+
This `*` character can be combined with an optional argument definition to allow zero or more instances of an argument:
279
+
280
+
mail:send {user?*}
281
+
277
282
<aname="option-arrays"></a>
278
283
#### Option Arrays
279
284
@@ -400,7 +405,7 @@ In addition, the `choice` method accepts optional fourth and fifth arguments for
400
405
<aname="writing-output"></a>
401
406
### Writing Output
402
407
403
-
To send output to the console, you may use the `line`, `info`, `comment`, `question` and `error` methods. Each of these methods will use appropriate ANSI colors for their purpose. For example, let's display some general information to the user. Typically, the `info` method will display in the console as green colored text:
408
+
To send output to the console, you may use the `line`, `info`, `comment`, `question`, `warn`, and `error` methods. Each of these methods will use appropriate ANSI colors for their purpose. For example, let's display some general information to the user. Typically, the `info` method will display in the console as green colored text:
404
409
405
410
/**
406
411
* Execute the console command.
@@ -583,10 +588,55 @@ If you would like to call another console command and suppress all of its output
583
588
'user' => 1, '--queue' => 'default'
584
589
]);
585
590
591
+
<aname="signal-handling"></a>
592
+
## Signal Handling
593
+
594
+
The Symfony Console component, which powers the Artisan console, allows you to indicate which process signals (if any) your command handles. For example, you may indicate that your command handles the `SIGINT` and `SIGTERM` signals.
595
+
596
+
To get started, you should implement the `Symfony\Component\Console\Command\SignalableCommandInterface` interface on your Artisan command class. This interface requires you to define two methods: `getSubscribedSignals` and `handleSignal`:
597
+
598
+
```php
599
+
<?php
600
+
601
+
use Symfony\Component\Console\Command\SignalableCommandInterface;
602
+
603
+
class StartServer extends Command implements SignalableCommandInterface
604
+
{
605
+
// ...
606
+
607
+
/**
608
+
* Get the list of signals handled by the command.
609
+
*
610
+
* @return array
611
+
*/
612
+
public function getSubscribedSignals(): array
613
+
{
614
+
return [SIGINT, SIGTERM];
615
+
}
616
+
617
+
/**
618
+
* Handle an incoming signal.
619
+
*
620
+
* @param int $signal
621
+
* @return void
622
+
*/
623
+
public function handleSignal(int $signal): void
624
+
{
625
+
if ($signal === SIGINT) {
626
+
$this->stopServer();
627
+
628
+
return;
629
+
}
630
+
}
631
+
}
632
+
```
633
+
634
+
As you might expect, the `getSubscribedSignals` method should return an array of the signals that your command can handle, while the `handleSignal` method receives the signal and can respond accordingly.
635
+
586
636
<aname="stub-customization"></a>
587
637
## Stub Customization
588
638
589
-
The Artisan console's `make` commands are used to create a variety of classes, such as controllers, jobs, migrations, and tests. These classes are generated using "stub" files that are populated with values based on your input. However, you may want to to make small changes to files generated by Artisan. To accomplish this, you may use the `stub:publish` command to publish the most common stubs to your application so that you can customize them:
639
+
The Artisan console's `make` commands are used to create a variety of classes, such as controllers, jobs, migrations, and tests. These classes are generated using "stub" files that are populated with values based on your input. However, you may want to make small changes to files generated by Artisan. To accomplish this, you may use the `stub:publish` command to publish the most common stubs to your application so that you can customize them:
Copy file name to clipboardExpand all lines: authentication.md
+14-11Lines changed: 14 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -37,7 +37,7 @@ At its core, Laravel's authentication facilities are made up of "guards" and "pr
37
37
38
38
Providers define how users are retrieved from your persistent storage. Laravel ships with support for retrieving users using [Eloquent](/docs/{{version}}/eloquent) and the database query builder. However, you are free to define additional providers as needed for your application.
39
39
40
-
Your application's authentication configuration file is located at `config/auth.php`. This file contains several welldocumented options for tweaking the behavior of Laravel's authentication services.
40
+
Your application's authentication configuration file is located at `config/auth.php`. This file contains several well-documented options for tweaking the behavior of Laravel's authentication services.
41
41
42
42
> {tip} Guards and providers should not be confused with "roles" and "permissions". To learn more about authorizing user actions via permissions, please refer to the [authorization](/docs/{{version}}/authorization) documentation.
43
43
@@ -46,7 +46,7 @@ Your application's authentication configuration file is located at `config/auth.
46
46
47
47
Want to get started fast? Install a [Laravel application starter kit](/docs/{{version}}/starter-kits) in a fresh Laravel application. After migrating your database, navigate your browser to `/register` or any other URL that is assigned to your application. The starter kits will take care of scaffolding your entire authentication system!
48
48
49
-
**Even if you choose to not use a starter kit in your final Laravel application, installing the [Laravel Breeze](/docs/{{version}}/starter-kits#laravel-breeze) starter kit can be a wonderful opportunity to learn how to implement all of Laravel's authentication functionality in an actual Laravel project.** Since Laravel Breeze creates authentication controllers, routes, and views for you, you can examine the code within these files to learn how Laravel's authentication features may be implemented.
49
+
**Even if you choose not to use a starter kit in your final Laravel application, installing the [Laravel Breeze](/docs/{{version}}/starter-kits#laravel-breeze) starter kit can be a wonderful opportunity to learn how to implement all of Laravel's authentication functionality in an actual Laravel project.** Since Laravel Breeze creates authentication controllers, routes, and views for you, you can examine the code within these files to learn how Laravel's authentication features may be implemented.
Laravel includes built-in authentication and session services which are typically accessed via the `Auth` and `Session` facades. These features provide cookiebased authentication for requests that are initiated from web browsers. They provide methods that allow you to verify a user's credentials and authenticate the user. In addition, these services will automatically store the proper authentication data in the user's session and issue the user's session cookie. A discussion of how to use these services is contained within this documentation.
72
+
Laravel includes built-in authentication and session services which are typically accessed via the `Auth` and `Session` facades. These features provide cookie-based authentication for requests that are initiated from web browsers. They provide methods that allow you to verify a user's credentials and authenticate the user. In addition, these services will automatically store the proper authentication data in the user's session and issue the user's session cookie. A discussion of how to use these services is contained within this documentation.
73
73
74
74
**Application Starter Kits**
75
75
@@ -121,7 +121,7 @@ And, if you would like to get started quickly, we are pleased to recommend [Lara
121
121
122
122
First, you should [install a Laravel application starter kit](/docs/{{version}}/starter-kits). Our current starter kits, Laravel Breeze and Laravel Jetstream, offer beautifully designed starting points for incorporating authentication into your fresh Laravel application.
123
123
124
-
Laravel Breeze is a minimal, simple implementation of all of Laravel's authentication features, including login, registration, password reset, email verification, and password confirmation. Laravel Breeze's view layer is made up of simple [Blade templates](/docs/{{version}}/blade) styled with [Tailwind CSS](https://tailwindcss.com).
124
+
Laravel Breeze is a minimal, simple implementation of all of Laravel's authentication features, including login, registration, password reset, email verification, and password confirmation. Laravel Breeze's view layer is made up of simple [Blade templates](/docs/{{version}}/blade) styled with [Tailwind CSS](https://tailwindcss.com). Breeze also offers an [Inertia](https://inertiajs.com) based scaffolding option using Vue or React.
125
125
126
126
[Laravel Jetstream](https://jetstream.laravel.com) is a more robust application starter kit that includes support for scaffolding your application with [Livewire](https://laravel-livewire.com) or [Inertia.js and Vue](https://inertiajs.com). In addition, Jetstream features optional support for two-factor authentication, teams, profile management, browser session management, API support via [Laravel Sanctum](/docs/{{version}}/sanctum), account deletion, and more.
127
127
@@ -217,9 +217,9 @@ If you are using the Laravel Breeze or Laravel Jetstream [starter kits](/docs/{{
217
217
<aname="authenticating-users"></a>
218
218
## Manually Authenticating Users
219
219
220
-
You are not required to use the authentication scaffolding included with Laravel's [application starter kits](/docs/{{version}}/starter-kits). If you choose to not use this scaffolding, you will need to manage user authentication using the Laravel authentication classes directly. Don't worry, it's a cinch!
220
+
You are not required to use the authentication scaffolding included with Laravel's [application starter kits](/docs/{{version}}/starter-kits). If you choose not to use this scaffolding, you will need to manage user authentication using the Laravel authentication classes directly. Don't worry, it's a cinch!
221
221
222
-
We will access Laravel's authentication services via the `Auth`[facade](/docs/{{version}}/facades), so we'll need to make sure to import the `Auth` facade at the top of the class. Next, let's check out the `attempt` method. The `attempt` method is normally used to handle authentication attempt's from your application's "login" form. If authentication is successful, you should regenerate the user's [session](/docs/{{version}}/session) to prevent [session fixation](https://en.wikipedia.org/wiki/Session_fixation):
222
+
We will access Laravel's authentication services via the `Auth`[facade](/docs/{{version}}/facades), so we'll need to make sure to import the `Auth` facade at the top of the class. Next, let's check out the `attempt` method. The `attempt` method is normally used to handle authentication attempts from your application's "login" form. If authentication is successful, you should regenerate the user's [session](/docs/{{version}}/session) to prevent [session fixation](https://en.wikipedia.org/wiki/Session_fixation):
223
223
224
224
<?php
225
225
@@ -233,12 +233,15 @@ We will access Laravel's authentication services via the `Auth` [facade](/docs/{
@@ -252,7 +255,7 @@ We will access Laravel's authentication services via the `Auth` [facade](/docs/{
252
255
}
253
256
}
254
257
255
-
The `attempt` method accepts an array of key / value pairs as its first argument. The values in the array will be used to find the user in your database table. So, in the example above, the user will be retrieved by the value of the `email` column. If the user is found, the hashed password stored in the database will be compared with the `password` value passed to the method via the array. You should not hash the incoming request's `password` value, since the framework will automatically hash the value before comparing it to the hashed password in the database. If the two hashed passwords match an authenticated session will be started for the user.
258
+
The `attempt` method accepts an array of key / value pairs as its first argument. The values in the array will be used to find the user in your database table. So, in the example above, the user will be retrieved by the value of the `email` column. If the user is found, the hashed password stored in the database will be compared with the `password` value passed to the method via the array. You should not hash the incoming request's `password` value, since the framework will automatically hash the value before comparing it to the hashed password in the database. An authenticated session will be started for the user if the two hashed passwords match.
256
259
257
260
Remember, Laravel's authentication services will retrieve users from your database based on your authentication guard's "provider" configuration. In the default `config/auth.php` configuration file, the Eloquent user provider is specified and it is instructed to use the `App\Models\User` model when retrieving users. You may change these values within your configuration file based on the needs of your application.
258
261
@@ -400,7 +403,7 @@ In addition to calling the `logout` method, it is recommended that you invalidat
400
403
/**
401
404
* Log the user out of the application.
402
405
*
403
-
* @param \Illuminate\Http\Request $request
406
+
* @param \Illuminate\Http\Request $request
404
407
* @return \Illuminate\Http\Response
405
408
*/
406
409
public function logout(Request $request)
@@ -453,7 +456,7 @@ After confirming their password, a user will not be asked to confirm their passw
453
456
<aname="the-password-confirmation-form"></a>
454
457
#### The Password Confirmation Form
455
458
456
-
First, we will define a route to display a view that requests that the user confirm their password:
459
+
First, we will define a route to display a view that requests the user to confirm their password:
0 commit comments