Skip to content

[11.x] document new cache driver #10032

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

Draft
wants to merge 161 commits into
base: 11.x
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
161 commits
Select commit Hold shift + click to select a range
f908fe3
Prep Laravel v12 (#9495)
driesvints Mar 13, 2024
1ee7342
Fix typo (#10001)
spoyntersmith Oct 29, 2024
cc06dbe
Add documentation about version constraint to validation docs (#10012)
shaedrich Nov 5, 2024
8c527b5
docs: update PHP CS Fixer spelling/link (#10025)
keradus Nov 12, 2024
93aed95
document new cache driver
browner12 Nov 19, 2024
bb0d238
fix conflicts
taylorotwell Jan 27, 2025
38946b4
[12.x] Document `image` rule SVG security changes (#10136)
SanderMuller Jan 27, 2025
f63817c
fix conflicts
taylorotwell Feb 17, 2025
49225e5
standardize `bash` vs `shell` code fence language (#10174)
browner12 Feb 18, 2025
74d0ee6
standardize "none/nothing" fenced code blocks (#10176)
browner12 Feb 18, 2025
a31393e
standardize `shell` and `sh` code block languages (#10175)
browner12 Feb 18, 2025
5496409
Merge branch '11.x'
taylorotwell Feb 18, 2025
1ab9932
[12.x] use fenced code blocks (#10172)
browner12 Feb 19, 2025
221277c
remove extra spaces (#10182)
browner12 Feb 19, 2025
1274dad
fix code fence language (#10185)
browner12 Feb 19, 2025
92f71c0
remove extra linebreaks (#10184)
browner12 Feb 19, 2025
1cd90c8
standardize ellipsis usage (#10187)
browner12 Feb 19, 2025
68c1d75
12.x Docs (#10188)
taylorotwell Feb 21, 2025
82f5b38
update trial docs
taylorotwell Feb 23, 2025
2935587
update react example
taylorotwell Feb 23, 2025
72aa9f5
shorten wording
taylorotwell Feb 23, 2025
86136d4
installer upgrade instructions
taylorotwell Feb 23, 2025
ba26bf5
update api docs
taylorotwell Feb 24, 2025
f15d17f
Add link to migrate Carbon from version 2 to 3 (#10198)
meduzen Feb 24, 2025
48d5f2a
Fix typos (#10200)
krsriq Feb 24, 2025
50830ba
[12.x] Upgrade guide entry for Multi-schema Database Inspecting (#10199)
hafezdivandari Feb 24, 2025
fcaed38
Fix typo (#10201)
pjsalita Feb 24, 2025
d0ecae6
[12.x] Added Laravel official Extension support (#10202)
akr4m Feb 24, 2025
c47fca3
Fix anchor link for assertServiceUnavailable and line break in Artisa…
monayemislam Feb 25, 2025
6c2fd51
[12.x] Add UUID v7 section for Models to upgrade guide (#10204)
HasanQQ Feb 25, 2025
3029128
document onlyInvalid
taylorotwell Feb 25, 2025
e82816b
streamline install docs
taylorotwell Feb 25, 2025
b1339c0
wip
taylorotwell Feb 25, 2025
fb08f92
fix conflicts
taylorotwell Feb 25, 2025
f146853
Added PHPUnit and PEST as dependency update (#10205)
iamlux20 Feb 26, 2025
7589d0d
Updated releases.md (#10211)
Rubaiyat-E-Mohammad Feb 27, 2025
296e2be
[12.x] Format code examples in helpers.md for consistency (#10210)
itsrafsanjani Feb 27, 2025
97e713d
fix link reference in installation documentation (#10207)
subhamchbty Feb 27, 2025
5d35bc1
correct version 11.x to 12.x (#10206)
pjsalita Feb 27, 2025
e06f293
[12.x] Add Str::uuid7 to string helpers (#10213)
christophstockinger Feb 27, 2025
6a37e9b
Update starter-kits.md (#10217)
Rat01047 Feb 28, 2025
554b6a8
[12.x] Add Arr::select method documentation (#10216)
alaminfirdows Feb 28, 2025
0815e22
update facade urls to new api doc links (#10222)
XbNz Mar 3, 2025
c5a35be
chore: Added note to notifications.md (#10223)
mattyforth Mar 3, 2025
e099b73
Fix 404 to GridFS documentation in mongodb.md (#10221)
Rkallenkoot Mar 3, 2025
5b8b207
Fix/remove extra backticks in code snippets in collections.md (#10224)
javedbaloch4 Mar 4, 2025
4a3b41f
Clarify ASCII numerals in `alpha_dash` and `alpha_num` validation rul…
austincarpenter Mar 4, 2025
c589443
add documentation for traditional livewire components in starter kit …
devinnived Mar 4, 2025
78ba6ed
Removed the duplicated use in the validation documentation sentence f…
AhmedAlaa4611 Mar 4, 2025
a90e202
document event stream customization
taylorotwell Mar 4, 2025
701d69c
Add documentation for `Context::scope()` (#10214)
cosmastech Mar 4, 2025
2251911
Ensuring logical consistency (#10228)
AhmedAlaa4611 Mar 5, 2025
5f3897d
Feat: Add Docs for Array Partition (#10227)
pandiselvamm Mar 5, 2025
6a9173a
Missing semi-colon in validation.md (#10230)
AhmedAlaa4611 Mar 5, 2025
bfcd66a
fix: remove unnecessary code blocks in file storage documentation (#1…
JsExpertCoder Mar 6, 2025
e4edae6
inertia ssr
taylorotwell Mar 6, 2025
87931ac
Fix API documentation URLs in Routing section (#10235)
mohammadrasoulasghari Mar 7, 2025
4dbcf97
Update cache.md (#10234)
kachelle Mar 7, 2025
b9e044e
add documentation for community maintained starter kits (#10236)
devinnived Mar 7, 2025
b9dc159
Fix markdown formatting. (#10241)
HiroKws Mar 10, 2025
bc982a5
Fix markdown formatting. (#10241)
HiroKws Mar 10, 2025
f86194a
[12.x] Mention different Vite integration for Tailwind v3 vs v4 (#10240)
rozsazoltan Mar 10, 2025
87fe8fc
Remove unnecessary fenced code blocks in strings.md (#10239)
marioagr Mar 10, 2025
607adcf
[12.x] Rework pagination Tailwind JIT description; add v4 syntax (#10…
rozsazoltan Mar 10, 2025
2fd7197
Update Logging Documentation to Use handler_with (#10242)
AhmedAlaa4611 Mar 12, 2025
e181b1c
[12.x] Document `ensureNotTimedOut` (#10231)
mattmcdev Mar 12, 2025
0c27677
[12.x] docs: document container respecting property default values (#…
calebdw Mar 13, 2025
d914fa3
Fix strings whenEmpty code example (#10249)
RobertBoes Mar 13, 2025
16ff347
Document 'only' and 'except' for blade attributes (#10248)
inmanturbo Mar 13, 2025
5253514
Update Logging Documentation to Use handler_with (#10247)
AhmedAlaa4611 Mar 13, 2025
0cc3f93
[12.x] Document `increment` and `decrement` (#10245)
mattmcdev Mar 13, 2025
8837a4b
Update the pagination docs to reflect the actual implementation (#10251)
AhmedAlaa4611 Mar 13, 2025
9a84c2f
document has one through
taylorotwell Mar 13, 2025
9b39f6e
Updating the docs to reflect the actual generated comment (#10252)
AhmedAlaa4611 Mar 14, 2025
2ae2817
wip
taylorotwell Mar 16, 2025
594fe1b
Fix typo in a Precognition for Alpine.js example (#10255)
johnRivs Mar 16, 2025
690f920
Consistency with Laravel's best practices (#10254)
AhmedAlaa4611 Mar 16, 2025
4223ed3
Fix markdown formatting (#10257)
AhmedAlaa4611 Mar 17, 2025
092db4e
Add documentation for getChanges (#10258)
Tamas-hi Mar 17, 2025
7305647
Explain redirectUsersTo functionality (#10253)
Rattone Mar 17, 2025
a89581b
Fix markdown formatting (#10259)
AhmedAlaa4611 Mar 17, 2025
6a0eec9
Fix markdown formatting (#10260)
AhmedAlaa4611 Mar 17, 2025
96617d0
Fix markdown formatting (#10261)
AhmedAlaa4611 Mar 18, 2025
91e9e4b
Use fenced code blocks (#10262)
AhmedAlaa4611 Mar 18, 2025
8131d17
wip
taylorotwell Mar 18, 2025
9d89b59
[12.x] Improve workOS docs (#10265)
arzola Mar 19, 2025
479d5fe
[12.x] Improve `anticipate` method example (#10264)
AhmedAlaa4611 Mar 19, 2025
d60c35d
Update Symfony documentation link to the latest maintained version (7…
AhmedAlaa4611 Mar 19, 2025
2fa3c52
Add missing import for clarity and to eliminate confusion (#10267)
AhmedAlaa4611 Mar 19, 2025
c858eff
[12.x] Add `ddBody` to http-tests.md (#10268)
Sammyjo20 Mar 20, 2025
598cf05
Ensure Proper Closure of File Handle in LazyCollection (#10269)
AhmedAlaa4611 Mar 20, 2025
c11c9cb
Improve PHPUnit Example to Match Pest Example in Testing Documentatio…
AhmedAlaa4611 Mar 22, 2025
413b069
sync indentation with framework formatting (#10272)
browner12 Mar 22, 2025
3a30b3d
Updating the docs to reflect the actual implementation (#10276)
AhmedAlaa4611 Mar 22, 2025
b489ae5
[12.x] Add schedule useCache example (#10273)
boserup Mar 22, 2025
a7e90ce
[12.x] Add `DatabaseTokenRepository` constructor signature update to …
jnoordsij Mar 22, 2025
379d9a5
[12.x] Cache Event List with Cache Flush and Missed Events (#10278)
tech-wolf-tw Mar 24, 2025
53a68fe
Improve `Collection::reduce` docs (#10282)
timacdonald Mar 27, 2025
cdcd3ca
Fix docs - pessimistic locking SQL (#10280)
nevstas Mar 27, 2025
9a51f36
docs: parameter is `$escape`, not `$escaped` (#10287)
danjohnson95 Mar 28, 2025
02192ad
Missing semi-colon (#10288)
AhmedAlaa4611 Mar 29, 2025
7e4adca
arr sole
taylorotwell Mar 29, 2025
3c910b6
as conditions
taylorotwell Mar 29, 2025
5e9ae53
assert doesnt throw
taylorotwell Mar 29, 2025
4c0e15c
Document the new `Migration::shouldRun()` feature (#10277)
inmanturbo Mar 29, 2025
fe846c6
Add missing imports in migration example (#10291)
AhmedAlaa4611 Mar 30, 2025
0a322f9
Remove unnecessary `once` (#10290)
jasonmccreary Mar 30, 2025
4fa8bb8
Ensure consistent formatting (#10293)
AhmedAlaa4611 Mar 31, 2025
ac72220
Correct remaining reference (#10294)
jasonmccreary Mar 31, 2025
6c86517
Remove Laravel Website, no github repo found (#10292)
ankitpsk Mar 31, 2025
1de335b
document new scopes
taylorotwell Mar 31, 2025
d8ade08
Add \Illuminate\Database\Schema\Blueprint changed constructor signatu…
restuff Apr 1, 2025
038d72d
Fix invalid JSON syntax (#10298)
AhmedAlaa4611 Apr 1, 2025
fd18bf0
[12.x] Add link to Laravel Tinker GitHub repository (#10299)
AhmedAlaa4611 Apr 1, 2025
902aaf9
Update Symfony documentation link to the latest maintained version (#…
AhmedAlaa4611 Apr 1, 2025
c22c311
update docs
taylorotwell Apr 3, 2025
7d1df16
[12.x] Nullsafe operator (#10304)
AhmedAlaa4611 Apr 3, 2025
ffb08b0
change "directory" to "file" in broadcasting configuration descriptio…
axdemelas Apr 4, 2025
c4f646c
Fix : Formatting markdown in blade.md (#10307)
AlainCis Apr 4, 2025
e22c77d
[12.x] Add support for Redis Unix socket connections with PhpRedis (#…
dansleboby Apr 4, 2025
1660ca3
Fix link formatting (#10309)
AhmedAlaa4611 Apr 4, 2025
de0cc80
Fix link formatting (#10310)
AhmedAlaa4611 Apr 5, 2025
29d8413
Use single quotes for string consistency (#10312)
AhmedAlaa4611 Apr 7, 2025
f81d2de
Improve consistency in countBy method description (#10313)
AhmedAlaa4611 Apr 7, 2025
61ea2b9
[12.x] Document `tap` and `pipe` methods on the query builder (#10303)
timacdonald Apr 7, 2025
3d9881a
Fix implode method examples to show actual return values (#10314)
AhmedAlaa4611 Apr 7, 2025
2e1efb9
Update Paginator / LengthAwarePaginator Instance Methods Table (#10317)
bennettblack Apr 8, 2025
89f67d3
[12.x] Document `fromJson` method on `collections` docs (#10316)
AhmedAlaa4611 Apr 8, 2025
217229a
document failed request
taylorotwell Apr 8, 2025
72904db
document whereAttachedTo
taylorotwell Apr 8, 2025
7457dd7
document any of
taylorotwell Apr 8, 2025
320e310
document auto discovery of resources
taylorotwell Apr 8, 2025
0b78bb4
automatic eager loading
taylorotwell Apr 8, 2025
b6829f9
remove bold
taylorotwell Apr 9, 2025
a8d4db9
Update queries.md (#10320)
sfolador Apr 9, 2025
52e15bd
Fixes missing `return` type
nunomaduro Apr 9, 2025
a77d8e7
Replace `die` with `dd` (#10322)
osbre Apr 10, 2025
47fed28
wip
taylorotwell Apr 10, 2025
9f8f242
fixed the incorrect output in scope context example (#10323)
MrPunyapal Apr 11, 2025
e98ac6b
[12.x] Document the optional argument on database transactions (#10321)
AhmedAlaa4611 Apr 15, 2025
cec5ac6
[12.x] Updating `packages.md` (#10329)
devajmeireles Apr 15, 2025
da87313
Update notifications.md (#10328)
zepfietje Apr 15, 2025
a3f5921
memo docs
taylorotwell Apr 15, 2025
694c3b5
wip
taylorotwell Apr 15, 2025
1c5372f
document uri
taylorotwell Apr 15, 2025
38c2a1a
wip
taylorotwell Apr 15, 2025
8576d22
wip
taylorotwell Apr 15, 2025
340d60f
wip
taylorotwell Apr 16, 2025
4fb3d91
document uri helper
taylorotwell Apr 16, 2025
faa5d5c
Adds Return Type to ```toSearchableArray``` method (#10332)
Dipesh79 Apr 18, 2025
f25d00a
Use consistent Blade syntax highlighting for @use directive examples …
AhmedAlaa4611 Apr 21, 2025
0adcedc
Added documentation for `spellOrdinal` in Number Facade (#10338)
achyutkneupane Apr 21, 2025
0ca1cfe
make it more clear what is happening with email RFC validation (#10340)
tanerkay Apr 22, 2025
6fdbe31
Correct a small formatting issue (#10339)
AhmedAlaa4611 Apr 22, 2025
45d6ce9
feat: [12.x] Prohibited If Declined and Prohibited If Accepted valida…
osama-98 Apr 22, 2025
4d09ace
[12.x] Group imports in Blade `@use` directive (#10333)
osbre Apr 22, 2025
9ec5d7e
Adds `AsColection::map()` section (#10327)
DarkGhostHunter Apr 22, 2025
1615524
[12.x] clarify how to "set" value objects with custom casts (#10342)
browner12 Apr 23, 2025
0bcc79f
prefix casts with "As" (#10343)
browner12 Apr 23, 2025
509ebaa
add fluent uri docs to url page
taylorotwell Apr 23, 2025
5ad225c
Merge branch '12.x' into AB-cache-password-resets
browner12 Apr 23, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
696 changes: 405 additions & 291 deletions artisan.md

Large diffs are not rendered by default.

656 changes: 368 additions & 288 deletions authentication.md

Large diffs are not rendered by default.

718 changes: 392 additions & 326 deletions authorization.md

Large diffs are not rendered by default.

1,880 changes: 1,112 additions & 768 deletions billing.md

Large diffs are not rendered by default.

490 changes: 276 additions & 214 deletions blade.md

Large diffs are not rendered by default.

514 changes: 283 additions & 231 deletions broadcasting.md

Large diffs are not rendered by default.

448 changes: 284 additions & 164 deletions cache.md

Large diffs are not rendered by default.

1,035 changes: 605 additions & 430 deletions cashier-paddle.md

Large diffs are not rendered by default.

3,713 changes: 2,083 additions & 1,630 deletions collections.md

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions concurrency.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ If you upgraded to Laravel 11.x from a Laravel 10.x application, you may need to

Laravel achieves concurrency by serializing the given closures and dispatching them to a hidden Artisan CLI command, which unserializes the closures and invokes it within its own PHP process. After the closure has been invoked, the resulting value is serialized back to the parent process.

The `Concurrency` facade supports three drivers: `process` (the default), `fork`, and `sync`.
The `Concurrency` facade supports three drivers: `process` (the default), `fork`, and `sync`.

The `fork` driver offers improved performance compared to the default `process` driver, but it may only be used within PHP's CLI context, as PHP does not support forking during web requests. Before using the `fork` driver, you need to install the `spatie/fork` package:

```bash
```shell
composer require spatie/fork
```

Expand Down Expand Up @@ -73,7 +73,7 @@ $results = Concurrency::driver('fork')->run(...);

Or, to change the default concurrency driver, you should publish the `concurrency` configuration file via the `config:publish` Artisan command and update the `default` option within the file:

```bash
```shell
php artisan config:publish concurrency
```

Expand Down
70 changes: 41 additions & 29 deletions configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Laravel's default `.env` file contains some common configuration values that may

If you are developing with a team, you may wish to continue including and updating the `.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.

> [!NOTE]
> [!NOTE]
> 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>
Expand Down Expand Up @@ -97,7 +97,9 @@ APP_NAME="My Application"

All of the variables listed in the `.env` file will be loaded into the `$_ENV` PHP super-global when your application receives a request. However, you may use the `env` function 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 function:

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

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.

Expand All @@ -106,21 +108,25 @@ The second value passed to the `env` function is the "default value". This value

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;
```php
use Illuminate\Support\Facades\App;

$environment = App::environment();
$environment = App::environment();
```

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
}
```php
if (App::environment('local')) {
// The environment is local
}

if (App::environment(['local', 'staging'])) {
// The environment is either local OR staging...
}
if (App::environment(['local', 'staging'])) {
// The environment is either local OR staging...
}
```

> [!NOTE]
> [!NOTE]
> The current application environment detection can be overridden by defining a server-level `APP_ENV` environment variable.

<a name="encrypting-environment-files"></a>
Expand All @@ -143,7 +149,7 @@ Running the `env:encrypt` command will encrypt your `.env` file and place the en
php artisan env:encrypt --key=3UVsEgGVK36XN82KKeyLFMhvosbZN1aF
```

> [!NOTE]
> [!NOTE]
> The length of the key provided should match the key length required by the encryption cipher being used. By default, Laravel will use the `AES-256-CBC` cipher which requires a 32 character key. You are free to use any cipher supported by Laravel's [encrypter](/docs/{{version}}/encryption) by passing the `--cipher` option when invoking the command.

If your application has multiple environment files, such as `.env` and `.env.staging`, you may specify the environment file that should be encrypted by providing the environment name via the `--env` option:
Expand Down Expand Up @@ -192,28 +198,34 @@ php artisan env:decrypt --force

You may easily access your configuration values using the `Config` facade or global `config` function from anywhere in your application. The configuration values may be accessed using "dot" syntax, which includes the name of the file and option you wish to access. A default value may also be specified and will be returned if the configuration option does not exist:

use Illuminate\Support\Facades\Config;
```php
use Illuminate\Support\Facades\Config;

$value = Config::get('app.timezone');
$value = Config::get('app.timezone');

$value = config('app.timezone');
$value = config('app.timezone');

// Retrieve a default value if the configuration value does not exist...
$value = config('app.timezone', 'Asia/Seoul');
// Retrieve a default value if the configuration value does not exist...
$value = config('app.timezone', 'Asia/Seoul');
```

To set configuration values at runtime, you may invoke the `Config` facade's `set` method or pass an array to the `config` function:

Config::set('app.timezone', 'America/Chicago');
```php
Config::set('app.timezone', 'America/Chicago');

config(['app.timezone' => 'America/Chicago']);
config(['app.timezone' => 'America/Chicago']);
```

To assist with static analysis, the `Config` facade also provides typed configuration retrieval methods. If the retrieved configuration value does not match the expected type, an exception will be thrown:

Config::string('config-key');
Config::integer('config-key');
Config::float('config-key');
Config::boolean('config-key');
Config::array('config-key');
```php
Config::string('config-key');
Config::integer('config-key');
Config::float('config-key');
Config::boolean('config-key');
Config::array('config-key');
```

<a name="configuration-caching"></a>
## Configuration Caching
Expand All @@ -232,7 +244,7 @@ The `config:clear` command may be used to purge the cached configuration:
php artisan config:clear
```

> [!WARNING]
> [!WARNING]
> 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; therefore, the `env` function will only return external, system level environment variables.

<a name="configuration-publishing"></a>
Expand All @@ -253,7 +265,7 @@ php artisan config:publish --all

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.

> [!WARNING]
> [!WARNING]
> 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>
Expand Down Expand Up @@ -302,7 +314,7 @@ php artisan down --with-secret

When accessing this hidden route, you will then be redirected to the `/` route of the application. Once the cookie has been issued to your browser, you will be able to browse the application normally as if it was not in maintenance mode.

> [!NOTE]
> [!NOTE]
> Your maintenance mode secret should typically consist of alpha-numeric characters and, optionally, dashes. You should avoid using characters that have special meaning in URLs such as `?` or `&`.

<a name="maintenance-mode-on-multiple-servers"></a>
Expand Down Expand Up @@ -346,7 +358,7 @@ To disable maintenance mode, use the `up` command:
php artisan up
```

> [!NOTE]
> [!NOTE]
> You may customize the default maintenance mode template by defining your own template at `resources/views/errors/503.blade.php`.

<a name="maintenance-mode-queues"></a>
Expand All @@ -357,4 +369,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 [Laravel Vapor](https://vapor.laravel.com) and [Envoyer](https://envoyer.io) to accomplish zero-downtime deployment with Laravel.
Since maintenance mode requires your application to have several seconds of downtime, consider running your applications on a fully-managed platform like [Laravel Cloud](https://cloud.laravel.com) to accomplish zero-downtime deployment with Laravel.
64 changes: 37 additions & 27 deletions console-tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,30 +33,36 @@ public function test_console_command(): void

You may use the `assertNotExitCode` method to assert that the command did not exit with a given exit code:

$this->artisan('inspire')->assertNotExitCode(1);
```php
$this->artisan('inspire')->assertNotExitCode(1);
```

Of course, all terminal commands typically exit with a status code of `0` when they are successful and a non-zero exit code when they are not successful. Therefore, for convenience, you may utilize the `assertSuccessful` and `assertFailed` assertions to assert that a given command exited with a successful exit code or not:

$this->artisan('inspire')->assertSuccessful();
```php
$this->artisan('inspire')->assertSuccessful();

$this->artisan('inspire')->assertFailed();
$this->artisan('inspire')->assertFailed();
```

<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?');
```php
Artisan::command('question', function () {
$name = $this->ask('What is your name?');

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

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

You may test this command with the following test:

Expand Down Expand Up @@ -133,8 +139,8 @@ test('console command', function () {
public function test_console_command(): void
{
$this->artisan('example')
->doesntExpectOutput()
->assertExitCode(0);
->doesntExpectOutput()
->assertExitCode(0);
}
```

Expand All @@ -155,8 +161,8 @@ test('console command', function () {
public function test_console_command(): void
{
$this->artisan('example')
->expectsOutputToContain('Taylor')
->assertExitCode(0);
->expectsOutputToContain('Taylor')
->assertExitCode(0);
}
```

Expand All @@ -165,23 +171,27 @@ public function test_console_command(): void

When writing a command which expects 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);
```php
$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, '[email protected]'],
[2, '[email protected]'],
]);
```php
$this->artisan('users:all')
->expectsTable([
'ID',
'Email',
], [
[1, '[email protected]'],
[2, '[email protected]'],
]);
```

<a name="console-events"></a>
## Console Events
Expand Down
Loading