Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation Revisions 2020 #6625

Merged
merged 297 commits into from Dec 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
297 commits
Select commit Hold shift + click to select a range
00ad3bc
wip
taylorotwell Nov 12, 2020
77660a3
wip
taylorotwell Nov 12, 2020
6f35443
wip
taylorotwell Nov 12, 2020
28871d8
wip
taylorotwell Nov 12, 2020
67d13ac
wip
taylorotwell Nov 12, 2020
c7daab2
wip
taylorotwell Nov 12, 2020
480ddb3
wip
taylorotwell Nov 12, 2020
174b688
wip
taylorotwell Nov 12, 2020
85ec294
wip"
taylorotwell Nov 12, 2020
249dc5a
wip
taylorotwell Nov 12, 2020
eeaac1a
update usage of closure
taylorotwell Nov 12, 2020
cbb094c
wip
taylorotwell Nov 12, 2020
20c4555
wip
taylorotwell Nov 12, 2020
244accc
wip
taylorotwell Nov 12, 2020
8197773
wip
taylorotwell Nov 13, 2020
c6e712a
add route example
taylorotwell Nov 13, 2020
ccd37ca
wip
taylorotwell Nov 13, 2020
3100520
wip
taylorotwell Nov 13, 2020
584ac6a
wip
taylorotwell Nov 13, 2020
168d9e1
wip
taylorotwell Nov 13, 2020
81c4f43
wip
taylorotwell Nov 13, 2020
4810cfb
wip
taylorotwell Nov 13, 2020
33ad4f8
wip
taylorotwell Nov 14, 2020
513d73e
wip
taylorotwell Nov 14, 2020
27432ad
wip
taylorotwell Nov 14, 2020
b2e204f
wip
taylorotwell Nov 14, 2020
40e442d
fix end statements
taylorotwell Nov 14, 2020
d28b027
wip
taylorotwell Nov 14, 2020
a0f1ab5
work on layout docs
taylorotwell Nov 14, 2020
d840cdd
Merge branch '8.x' into onboarding
taylorotwell Nov 14, 2020
4ddc6fd
Merge branch '8.x' into onboarding
taylorotwell Nov 15, 2020
615acdc
fortify note
taylorotwell Nov 16, 2020
b558218
wip
taylorotwell Nov 16, 2020
9475017
wip
taylorotwell Nov 16, 2020
0c4c524
wip
taylorotwell Nov 16, 2020
1f93c8e
wip
taylorotwell Nov 16, 2020
c58cd51
wip
taylorotwell Nov 16, 2020
497eb3e
wip
taylorotwell Nov 16, 2020
5b2efbe
wip
taylorotwell Nov 16, 2020
f7e5faf
wip
taylorotwell Nov 16, 2020
089118f
wip
taylorotwell Nov 16, 2020
0585604
wip
taylorotwell Nov 16, 2020
56c17c4
wip
taylorotwell Nov 16, 2020
cb2267a
wip
taylorotwell Nov 16, 2020
cdc64f8
fix link
taylorotwell Nov 16, 2020
09e6ccc
wip
taylorotwell Nov 16, 2020
6e3ee82
wip
taylorotwell Nov 17, 2020
79b62db
wip
taylorotwell Nov 17, 2020
eda0b47
wip
taylorotwell Nov 17, 2020
afe3848
wip
taylorotwell Nov 17, 2020
721b534
wip
taylorotwell Nov 17, 2020
8115b27
wip
taylorotwell Nov 17, 2020
23b3b1c
wip
taylorotwell Nov 17, 2020
ee8a1c5
wip
taylorotwell Nov 17, 2020
39b9327
wip
taylorotwell Nov 17, 2020
811b0b4
wip
taylorotwell Nov 18, 2020
801886e
wip
taylorotwell Nov 18, 2020
d1383b2
Merge branch '8.x' into onboarding
taylorotwell Nov 18, 2020
e7f3dd6
wip
taylorotwell Nov 18, 2020
aef9613
wip
taylorotwell Nov 18, 2020
08c4c9e
wip
taylorotwell Nov 18, 2020
7670c0b
wip
taylorotwell Nov 18, 2020
d220ea4
remove space
taylorotwell Nov 18, 2020
41e1092
fix conflicts
taylorotwell Nov 18, 2020
7532ccf
tailwind
taylorotwell Nov 18, 2020
57ca099
wip
taylorotwell Nov 18, 2020
f8800e7
wip
taylorotwell Nov 18, 2020
4a45b9a
wip
taylorotwell Nov 18, 2020
e0c5ad9
wip
taylorotwell Nov 18, 2020
63a09f3
wip
taylorotwell Nov 18, 2020
48a1f8c
wip
taylorotwell Nov 18, 2020
02f6b94
wip
taylorotwell Nov 18, 2020
e08469f
wip
taylorotwell Nov 19, 2020
5c607d0
wip
taylorotwell Nov 19, 2020
eb33774
wip
taylorotwell Nov 19, 2020
2574aba
wip
taylorotwell Nov 19, 2020
a614b22
wip
taylorotwell Nov 19, 2020
0043070
wip
taylorotwell Nov 19, 2020
5b43f71
wip
taylorotwell Nov 19, 2020
4f9f3fe
wip
taylorotwell Nov 19, 2020
af21580
wip
taylorotwell Nov 19, 2020
5d12711
wip
taylorotwell Nov 19, 2020
febc7d2
Merge branch '8.x' into onboarding
taylorotwell Nov 19, 2020
9744aec
wip
taylorotwell Nov 19, 2020
0aa9329
wip
taylorotwell Nov 19, 2020
616cd13
wip
taylorotwell Nov 19, 2020
57504f4
wip
taylorotwell Nov 19, 2020
671a620
wip
taylorotwell Nov 19, 2020
0217b37
wip
taylorotwell Nov 19, 2020
6870df5
wip
taylorotwell Nov 20, 2020
193c551
wip
taylorotwell Nov 20, 2020
78d1324
wip
taylorotwell Nov 20, 2020
f80d984
change link order
taylorotwell Nov 20, 2020
c412934
wip
taylorotwell Nov 20, 2020
34f44c1
wip
taylorotwell Nov 20, 2020
ab8ecac
wip
taylorotwell Nov 20, 2020
2fd3483
wip
taylorotwell Nov 20, 2020
a483d68
wip
taylorotwell Nov 20, 2020
a39cbda
wip
taylorotwell Nov 20, 2020
808efbf
wip
taylorotwell Nov 20, 2020
20e0da7
wip
taylorotwell Nov 20, 2020
6332569
wip
taylorotwell Nov 20, 2020
3441391
wip
taylorotwell Nov 20, 2020
706bb97
wip
taylorotwell Nov 20, 2020
7fc3980
wip
taylorotwell Nov 20, 2020
4a2edb4
wip
taylorotwell Nov 20, 2020
6c6bcd4
fix conflicts
taylorotwell Nov 21, 2020
055c933
wip
taylorotwell Nov 21, 2020
cc774b5
wip
taylorotwell Nov 21, 2020
e59a31a
wip
taylorotwell Nov 21, 2020
edb23d9
wip
taylorotwell Nov 21, 2020
c64ce30
wip
taylorotwell Nov 21, 2020
5453a9c
wip
taylorotwell Nov 21, 2020
2c72321
wip
taylorotwell Nov 21, 2020
7690205
Merge branch '8.x' into onboarding
taylorotwell Nov 23, 2020
889cdd3
wip
taylorotwell Nov 23, 2020
63e8cd1
wip
taylorotwell Nov 23, 2020
565e83c
wip
taylorotwell Nov 23, 2020
10f9301
wip
taylorotwell Nov 23, 2020
1bcad00
wip
taylorotwell Nov 23, 2020
b2cf91a
fix conflicts
taylorotwell Nov 24, 2020
02243d9
document sorting by multiple columns
taylorotwell Nov 24, 2020
e565b19
show other syntax
taylorotwell Nov 24, 2020
f1ec287
update links
taylorotwell Nov 24, 2020
353b4a4
update links
taylorotwell Nov 24, 2020
38d1722
wip
taylorotwell Nov 24, 2020
867f930
wip
taylorotwell Nov 24, 2020
0f16d14
wip
taylorotwell Nov 24, 2020
7fb81c4
wip
taylorotwell Nov 24, 2020
63459f8
wip
taylorotwell Nov 24, 2020
41849a8
wip
taylorotwell Nov 24, 2020
45c7271
wip
taylorotwell Nov 24, 2020
8e8bc1e
wip
taylorotwell Nov 24, 2020
5e5b244
wip
taylorotwell Nov 24, 2020
380caee
document lua scripting
taylorotwell Nov 24, 2020
ff6d2ef
Merge branch '8.x' into onboarding
taylorotwell Nov 25, 2020
0744fa4
Merge branch '8.x' into onboarding
taylorotwell Nov 25, 2020
9686da5
fix conflicts
taylorotwell Nov 25, 2020
728cd40
wip
taylorotwell Nov 25, 2020
4131c72
wip
taylorotwell Nov 25, 2020
6848971
wip
taylorotwell Nov 25, 2020
c226925
wip
taylorotwell Nov 25, 2020
e585992
wip
taylorotwell Nov 25, 2020
8cc7a95
wip
taylorotwell Nov 25, 2020
9c1b09e
wip
taylorotwell Nov 25, 2020
44a8ffb
wip
taylorotwell Nov 25, 2020
d72a829
wip
taylorotwell Nov 25, 2020
f38448a
wip
taylorotwell Nov 25, 2020
6b002eb
wip
taylorotwell Nov 25, 2020
83f622a
wip
taylorotwell Nov 25, 2020
760bf5b
use better example
taylorotwell Nov 25, 2020
4f3b11b
fix conflicts
taylorotwell Nov 26, 2020
d399daf
Merge branch '8.x' into onboarding
taylorotwell Nov 26, 2020
719b84b
wip
taylorotwell Nov 26, 2020
e951681
wip
taylorotwell Nov 26, 2020
e14b860
wip
taylorotwell Nov 26, 2020
df1a5ee
wip
taylorotwell Nov 26, 2020
1006151
fix conflicts
taylorotwell Nov 27, 2020
127de74
formatting
taylorotwell Nov 27, 2020
d1db679
make note about runtime config
taylorotwell Nov 27, 2020
db14dd1
wip
taylorotwell Nov 27, 2020
1001220
wip
taylorotwell Nov 27, 2020
63bc16e
wip
taylorotwell Nov 27, 2020
f3836a6
wip
taylorotwell Nov 27, 2020
9fb2547
wip
taylorotwell Nov 27, 2020
4b0352c
wip
taylorotwell Nov 27, 2020
eef6529
wip
taylorotwell Nov 27, 2020
1381fda
wip
taylorotwell Nov 27, 2020
0ed3f0a
wip
taylorotwell Nov 27, 2020
7c878d9
wip
taylorotwell Nov 27, 2020
3d1994f
wip
taylorotwell Nov 27, 2020
f377a88
wip
taylorotwell Nov 27, 2020
78dd7df
wip
taylorotwell Nov 29, 2020
732a39f
wip
taylorotwell Nov 29, 2020
294c34b
cleaning up validatoin
taylorotwell Nov 30, 2020
e3c01f8
table expectations
taylorotwell Nov 30, 2020
47ddfb7
wip
taylorotwell Nov 30, 2020
4cd1d94
wip
taylorotwell Nov 30, 2020
978b5f2
wip
taylorotwell Nov 30, 2020
3592ad1
wip
taylorotwell Nov 30, 2020
a9d0154
wip
taylorotwell Nov 30, 2020
a30371a
wip
taylorotwell Nov 30, 2020
81dc21a
wip
taylorotwell Nov 30, 2020
a749ddb
wip
taylorotwell Nov 30, 2020
b9bd67d
wip
taylorotwell Nov 30, 2020
d953a94
wip
taylorotwell Nov 30, 2020
198d3be
wip
taylorotwell Nov 30, 2020
6f0dec6
Merge branch '8.x' into onboarding
taylorotwell Dec 1, 2020
cbd7d1e
document batches
taylorotwell Dec 1, 2020
e03e109
wip
taylorotwell Dec 1, 2020
14d00db
wip
taylorotwell Dec 1, 2020
c2667c6
wip
taylorotwell Dec 1, 2020
715cc87
wip
taylorotwell Dec 1, 2020
4dc2472
wip
taylorotwell Dec 1, 2020
e300c1e
wip
taylorotwell Dec 1, 2020
88aa36e
wip
taylorotwell Dec 1, 2020
093ca7d
wip
taylorotwell Dec 1, 2020
e0336a9
wip
taylorotwell Dec 1, 2020
c86f423
wip
taylorotwell Dec 1, 2020
dd786e4
wip
taylorotwell Dec 1, 2020
1998283
wip
taylorotwell Dec 1, 2020
b8ddd6e
wip
taylorotwell Dec 1, 2020
60b8f25
wip
taylorotwell Dec 2, 2020
1ec91ce
wip
taylorotwell Dec 2, 2020
7e0919c
wip
taylorotwell Dec 2, 2020
6ba9703
wip
taylorotwell Dec 2, 2020
ccf7de9
wip
taylorotwell Dec 2, 2020
14a9e6d
wip
taylorotwell Dec 2, 2020
e74d973
wip
taylorotwell Dec 2, 2020
460d591
wip
taylorotwell Dec 2, 2020
3b1401c
wip
taylorotwell Dec 2, 2020
fb7c99f
wip
taylorotwell Dec 2, 2020
f741dc6
wip
taylorotwell Dec 3, 2020
c9888e6
wip
taylorotwell Dec 3, 2020
1849ba2
wip
taylorotwell Dec 3, 2020
ff65c56
wip
taylorotwell Dec 3, 2020
03c7351
wip
taylorotwell Dec 3, 2020
0ac991a
wip
taylorotwell Dec 3, 2020
ba68b8b
wip
taylorotwell Dec 3, 2020
632bca1
wip
taylorotwell Dec 4, 2020
0e35b97
wip
taylorotwell Dec 4, 2020
31496e2
wip
taylorotwell Dec 4, 2020
b424ef4
Merge branch '8.x' into onboarding
taylorotwell Dec 4, 2020
21a40de
wip
taylorotwell Dec 4, 2020
253f5bb
Merge branch '8.x' into onboarding
taylorotwell Dec 4, 2020
d469378
Merge branch '8.x' into onboarding
taylorotwell Dec 4, 2020
eac5080
Merge branch '8.x' into onboarding
taylorotwell Dec 4, 2020
0e1ef4d
content negotiation
taylorotwell Dec 4, 2020
f4f46f7
wip
taylorotwell Dec 4, 2020
fac91e0
wip
taylorotwell Dec 4, 2020
6bdc5a9
add introduction
taylorotwell Dec 4, 2020
3c058f4
update mix docs
taylorotwell Dec 4, 2020
d8bac78
wip
taylorotwell Dec 4, 2020
c0a686e
wip
taylorotwell Dec 4, 2020
df49ac0
wip
taylorotwell Dec 4, 2020
97bafe4
wip
taylorotwell Dec 4, 2020
ee17f9f
fix conflicts
taylorotwell Dec 7, 2020
fe44966
Merge branch '8.x' into onboarding
taylorotwell Dec 7, 2020
eb7a6ef
wip
taylorotwell Dec 7, 2020
4dd6b89
wip
taylorotwell Dec 7, 2020
8edcb35
wip
taylorotwell Dec 7, 2020
675c6f6
wip
taylorotwell Dec 7, 2020
7224484
wip
taylorotwell Dec 7, 2020
dad76dc
wip
taylorotwell Dec 7, 2020
0952356
wip
taylorotwell Dec 7, 2020
838f870
wip
taylorotwell Dec 7, 2020
2b04d00
wip
taylorotwell Dec 8, 2020
7b8c6b6
wip
taylorotwell Dec 8, 2020
c407403
wip
taylorotwell Dec 8, 2020
16d0938
add note
taylorotwell Dec 8, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
258 changes: 149 additions & 109 deletions artisan.md

Large diffs are not rendered by default.

326 changes: 172 additions & 154 deletions authentication.md

Large diffs are not rendered by default.

379 changes: 245 additions & 134 deletions authorization.md

Large diffs are not rendered by default.

640 changes: 365 additions & 275 deletions billing.md

Large diffs are not rendered by default.

740 changes: 434 additions & 306 deletions blade.md

Large diffs are not rendered by default.

407 changes: 240 additions & 167 deletions broadcasting.md

Large diffs are not rendered by default.

100 changes: 57 additions & 43 deletions cache.md

Large diffs are not rendered by default.

476 changes: 280 additions & 196 deletions cashier-paddle.md

Large diffs are not rendered by default.

380 changes: 246 additions & 134 deletions collections.md

Large diffs are not rendered by default.

69 changes: 29 additions & 40 deletions configuration.md
Expand Up @@ -8,30 +8,38 @@
- [Hiding Environment Variables From Debug Pages](#hiding-environment-variables-from-debug)
- [Accessing Configuration Values](#accessing-configuration-values)
- [Configuration Caching](#configuration-caching)
- [Debug Mode](#debug-mode)
- [Maintenance Mode](#maintenance-mode)

<a name="introduction"></a>
## Introduction

All of the configuration files for the Laravel framework are stored in the `config` directory. Each option is documented, so feel free to look through the files and get familiar with the options available to you.

These configuration files allow you to configure things like your database connection information, your mail server information, as well as various other core configuration values such as your application timezone and encryption key.

<a name="environment-configuration"></a>
## Environment Configuration

It is often helpful to have different configuration values based on the environment where the application is running. For example, you may wish to use a different cache driver locally than you do on your production server.

To make this a cinch, Laravel utilizes the [DotEnv](https://github.com/vlucas/phpdotenv) PHP library by Vance Lucas. In a fresh Laravel installation, the root directory of your application will contain a `.env.example` file. If you install Laravel via Composer, this file will automatically be copied to `.env`. Otherwise, you should copy the file manually.
To make this a cinch, Laravel utilizes the [DotEnv](https://github.com/vlucas/phpdotenv) PHP library. In a fresh Laravel installation, the root directory of your application will contain a `.env.example` file that defines many common environment variables. During the Laravel installation process, this file will automatically be copied to `.env`.

Your `.env` file should not be committed to your application's source control, since each developer / server using your application could require a different environment configuration. Furthermore, this would be a security risk in the event an intruder gains access to your source control repository, since any sensitive credentials would get exposed.
Laravel's default `.env` file contains some common configuration values that may differ based on whether your application is running locally or on a production web server. These values are then retrieved from various Laravel configuration files within the `config` directory using Laravel's `env` function.

If you are developing with a team, you may wish to continue including a `.env.example` file with your application. By putting placeholder values in the example configuration file, other developers on your team can clearly see which environment variables are needed to run your application. You may also create a `.env.testing` file. This file will override the `.env` file when running PHPUnit tests or executing Artisan commands with the `--env=testing` option.
If you are developing with a team, you may wish to continue including a `.env.example` file with your application. By putting placeholder values in the example configuration file, other developers on your team can clearly see which environment variables are needed to run your application.

> {tip} Any variable in your `.env` file can be overridden by external environment variables such as server-level or system-level environment variables.

<a name="environment-file-security"></a>
#### Environment File Security

Your `.env` file should not be committed to your application's source control, since each developer / server using your application could require a different environment configuration. Furthermore, this would be a security risk in the event an intruder gains access to your source control repository, since any sensitive credentials would get exposed.

<a name="environment-variable-types"></a>
### Environment Variable Types

All variables in your `.env` files are parsed as strings, so some reserved values have been created to allow you to return a wider range of types from the `env()` function:
All variables in your `.env` files are typically parsed as strings, so some reserved values have been created to allow you to return a wider range of types from the `env()` function:

`.env` Value | `env()` Value
------------- | -------------
Expand All @@ -44,27 +52,29 @@ empty | (string) ''
null | (null) null
(null) | (null) null

If you need to define an environment variable with a value that contains spaces, you may do so by enclosing the value in double quotes.
If you need to define an environment variable with a value that contains spaces, you may do so by enclosing the value in double quotes:

APP_NAME="My Application"

<a name="retrieving-environment-configuration"></a>
### Retrieving Environment Configuration

All of the variables listed in this file will be loaded into the `$_ENV` PHP super-global when your application receives a request. However, you may use the `env` helper to retrieve values from these variables in your configuration files. In fact, if you review the Laravel configuration files, you will notice several of the options already using this helper:
All of the variables listed in this file will be loaded into the `$_ENV` PHP super-global when your application receives a request. However, you may use the `env` helper to retrieve values from these variables in your configuration files. In fact, if you review the Laravel configuration files, you will notice many of the options are already using this helper:

'debug' => env('APP_DEBUG', false),

The second value passed to the `env` function is the "default value". This value will be used if no environment variable exists for the given key.
The second value passed to the `env` function is the "default value". This value will be returned if no environment variable exists for the given key.

<a name="determining-the-current-environment"></a>
### Determining The Current Environment

The current application environment is determined via the `APP_ENV` variable from your `.env` file. You may access this value via the `environment` method on the `App` [facade](/docs/{{version}}/facades):

use Illuminate\Support\Facades\App;

$environment = App::environment();

You may also pass arguments to the `environment` method to check if the environment matches a given value. The method will return `true` if the environment matches any of the given values:
You may also pass arguments to the `environment` method to determine if the environment matches a given value. The method will return `true` if the environment matches any of the given values:

if (App::environment('local')) {
// The environment is local
Expand All @@ -74,35 +84,7 @@ You may also pass arguments to the `environment` method to check if the environm
// The environment is either local OR staging...
}

> {tip} The current application environment detection can be overridden by a server-level `APP_ENV` environment variable. This can be useful when you need to share the same application for different environment configurations, so you can set up a given host to match a given environment in your server's configurations.

<a name="hiding-environment-variables-from-debug"></a>
### Hiding Environment Variables From Debug Pages

When an exception is uncaught and the `APP_DEBUG` environment variable is `true`, the debug page will show all environment variables and their contents. In some cases you may want to obscure certain variables. You may do this by updating the `debug_hide` option in your `config/app.php` configuration file.

Some variables are available in both the environment variables and the server / request data. Therefore, you may need to hide them for both `$_ENV` and `$_SERVER`:

return [

// ...

'debug_hide' => [
'_ENV' => [
'APP_KEY',
'DB_PASSWORD',
],

'_SERVER' => [
'APP_KEY',
'DB_PASSWORD',
],

'_POST' => [
'password',
],
],
];
> {tip} The current application environment detection can be overridden by defining a server-level `APP_ENV` environment variable.

<a name="accessing-configuration-values"></a>
## Accessing Configuration Values
Expand All @@ -121,12 +103,19 @@ To set configuration values at runtime, pass an array to the `config` helper:
<a name="configuration-caching"></a>
## Configuration Caching

To give your application a speed boost, you should cache all of your configuration files into a single file using the `config:cache` Artisan command. This will combine all of the configuration options for your application into a single file which will be loaded quickly by the framework.
To give your application a speed boost, you should cache all of your configuration files into a single file using the `config:cache` Artisan command. This will combine all of the configuration options for your application into a single file which can be quickly loaded by the framework.

You should typically run the `php artisan config:cache` command as part of your production deployment routine. The command should not be run during local development as configuration options will frequently need to be changed during the course of your application's development.
You should typically run the `php artisan config:cache` command as part of your production deployment process. The command should not be run during local development as configuration options will frequently need to be changed during the course of your application's development.

> {note} If you execute the `config:cache` command during your deployment process, you should be sure that you are only calling the `env` function from within your configuration files. Once the configuration has been cached, the `.env` file will not be loaded and all calls to the `env` function will return `null`.

<a name="debug-mode"></a>
## Debug Mode

The `debug` option in your `config/app.php` configuration file determines how much information about an error is actually displayed to the user. By default, this option is set to respect the value of the `APP_DEBUG` environment variable, which is stored in your `.env` file.

For local development, you should set the `APP_DEBUG` environment variable to `true`. **In your production environment, this value should always be `false`. If the variable is set to `true` in production, you risk exposing sensitive configuration values to your application's end users.**

<a name="maintenance-mode"></a>
## Maintenance Mode

Expand Down Expand Up @@ -186,4 +175,4 @@ While your application is in maintenance mode, no [queued jobs](/docs/{{version}
<a name="alternatives-to-maintenance-mode"></a>
#### Alternatives To Maintenance Mode

Since maintenance mode requires your application to have several seconds of downtime, consider alternatives like [Envoyer](https://envoyer.io) to accomplish zero-downtime deployment with Laravel.
Since maintenance mode requires your application to have several seconds of downtime, consider alternatives like [Laravel Vapor](https://vapor.laravel.com) and [Envoyer](https://envoyer.io) to accomplish zero-downtime deployment with Laravel.
36 changes: 27 additions & 9 deletions console-tests.md
@@ -1,31 +1,31 @@
# Console Tests

- [Introduction](#introduction)
- [Expecting Input / Output](#expecting-input-and-output)
- [Input / Output Expectations](#input-output-expectations)

<a name="introduction"></a>
## Introduction

In addition to simplifying HTTP testing, Laravel provides a simple API for testing console applications that ask for user input.
In addition to simplifying HTTP testing, Laravel provides a simple API for testing your application's [custom console commands](/docs/{{version}}/artisan).

<a name="expecting-input-and-output"></a>
## Expecting Input / Output
<a name="input-output-expectations"></a>
## Input / Output Expectations

Laravel allows you to easily "mock" user input for your console commands using the `expectsQuestion` method. In addition, you may specify the exit code and text that you expect to be output by the console command using the `assertExitCode` and `expectsOutput` methods. For example, consider the following console command:

Artisan::command('question', function () {
$name = $this->ask('What is your name?');

$language = $this->choice('Which language do you program in?', [
$language = $this->choice('Which language do you prefer?', [
'PHP',
'Ruby',
'Python',
]);

$this->line('Your name is '.$name.' and you program in '.$language.'.');
$this->line('Your name is '.$name.' and you prefer '.$language.'.');
});

You may test this command with the following test which utilizes the `expectsQuestion`, `expectsOutput`, and `assertExitCode` methods:
You may test this command with the following test which utilizes the `expectsQuestion`, `expectsOutput`, `doesntExpectOutput`, and `assertExitCode` methods:

/**
* Test a console command.
Expand All @@ -36,13 +36,31 @@ You may test this command with the following test which utilizes the `expectsQue
{
$this->artisan('question')
->expectsQuestion('What is your name?', 'Taylor Otwell')
->expectsQuestion('Which language do you program in?', 'PHP')
->expectsOutput('Your name is Taylor Otwell and you program in PHP.')
->expectsQuestion('Which language do you prefer?', 'PHP')
->expectsOutput('Your name is Taylor Otwell and you prefer PHP.')
->doesntExpectOutput('Your name is Taylor Otwell and you prefer Ruby.')
->assertExitCode(0);
}

<a name="confirmation-expectations"></a>
#### Confirmation Expectations

When writing a command which expects a confirmation in the form of a "yes" or "no" answer, you may utilize the `expectsConfirmation` method:

$this->artisan('module:import')
->expectsConfirmation('Do you really wish to run this command?', 'no')
->assertExitCode(1);

<a name="table-expectations"></a>
#### Table Expectations

If your command displays a table of information using Artisan's `table` method, it can be cumbersome to write output expectations for the entire table. Instead, you may use the `expectsTable` method. This method accepts the table's headers as its first argument and the table's data as its second argument:

$this->artisan('users:all')
->expectsTable([
'ID',
'Email',
], [
[1, 'taylor@example.com'],
[2, 'abigail@example.com'],
]);