Skip to content

Improve code format #9781

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

Closed
wants to merge 89 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
6eb7202
Improve code formatting
TENIOS Jul 19, 2024
55d8994
wip
TENIOS Jul 19, 2024
f6aa0e0
Update billing.md
TENIOS Jul 19, 2024
3341150
Update blade.md
TENIOS Jul 19, 2024
c2ca5db
Update broadcasting.md
TENIOS Jul 19, 2024
2aa5ade
Update cache.md
TENIOS Jul 19, 2024
2c29952
Update cashier-paddle.md
TENIOS Jul 19, 2024
3e00318
Update collections.md
TENIOS Jul 19, 2024
c956f90
Update configuration.md
TENIOS Jul 19, 2024
2bf90cb
Update console-tests.md
TENIOS Jul 19, 2024
edef71c
Update container.md
TENIOS Jul 19, 2024
8ca8e13
Update context.md
TENIOS Jul 19, 2024
a7485a0
Update contracts.md
TENIOS Jul 19, 2024
62cd9ed
Update contributions.md
TENIOS Jul 19, 2024
a1779a7
Update controllers.md
TENIOS Jul 19, 2024
4a462f1
Update csrf.md
TENIOS Jul 19, 2024
18ebcd3
Update database-testing.md
TENIOS Jul 19, 2024
b2b9b70
Update database.md
TENIOS Jul 19, 2024
bd94f15
Update deployment.md
TENIOS Jul 19, 2024
f3a476e
Update dusk.md
TENIOS Jul 19, 2024
7fd1963
Update eloquent-collections.md
TENIOS Jul 19, 2024
1c2382a
Update eloquent-factories.md
TENIOS Jul 19, 2024
3090142
Update eloquent-mutators.md
TENIOS Jul 19, 2024
abe3d71
Update eloquent-relationships.md
TENIOS Jul 19, 2024
8ba9753
Update eloquent-resources.md
TENIOS Jul 19, 2024
ac8f161
Update eloquent-serialization.md
TENIOS Jul 19, 2024
bdbf3fe
Update eloquent.md
TENIOS Jul 19, 2024
cdb0b13
Update encryption.md
TENIOS Jul 19, 2024
2d5931f
Update envoy.md
TENIOS Jul 19, 2024
a8e1dd2
Update errors.md
TENIOS Jul 19, 2024
25ff57d
Update events.md
TENIOS Jul 19, 2024
ef391ab
Update facades.md
TENIOS Jul 19, 2024
4615e33
Update filesystem.md
TENIOS Jul 19, 2024
61d9a8b
Update folio.md
TENIOS Jul 19, 2024
9964409
Update fortify.md
TENIOS Jul 19, 2024
d1f1c2e
Update hashing.md
TENIOS Jul 19, 2024
17e5a2a
Update helpers.md
TENIOS Jul 19, 2024
ed77829
Update homestead.md
TENIOS Jul 19, 2024
4053de3
Update horizon.md
TENIOS Jul 19, 2024
a94d91c
Update http-client.md
TENIOS Jul 19, 2024
01dd69d
Update http-tests.md
TENIOS Jul 19, 2024
7a22840
Update localization.md
TENIOS Jul 19, 2024
d493e11
Update logging.md
TENIOS Jul 19, 2024
11409a8
Update mail.md
TENIOS Jul 19, 2024
458f855
Update middleware.md
TENIOS Jul 19, 2024
741e9c6
Update migrations.md
TENIOS Jul 19, 2024
ed66d2e
Update mocking.md
TENIOS Jul 19, 2024
bf4c80e
Update notifications.md
TENIOS Jul 19, 2024
0beacac
Update packages.md
TENIOS Jul 19, 2024
f6f1069
Update pagination.md
TENIOS Jul 19, 2024
1c05ff4
Update passport.md
TENIOS Jul 19, 2024
4400e65
Update passwords.md
TENIOS Jul 19, 2024
40f6391
Update pennant.md
TENIOS Jul 19, 2024
e39eea5
Merge remote-tracking branch 'upstream/11.x' into improve-code-format
TENIOS Jul 19, 2024
b1af0ad
Fix whitespaces
TENIOS Jul 19, 2024
cb26c31
Update processes.md
TENIOS Jul 19, 2024
1e76d23
Update prompts.md
TENIOS Jul 19, 2024
41a3780
Update providers.md
TENIOS Jul 19, 2024
f22d59e
Update pulse.md
TENIOS Jul 19, 2024
65bb1cb
Update queries.md
TENIOS Jul 19, 2024
c1fc8b3
Update queues.md
TENIOS Jul 19, 2024
490ec03
Update rate-limiting.md
TENIOS Jul 19, 2024
5594e63
Update redirects.md
TENIOS Jul 19, 2024
2ff77c3
Update redis.md
TENIOS Jul 19, 2024
d001e8f
Update releases.md
TENIOS Jul 19, 2024
6eaa357
Update requests.md
TENIOS Jul 19, 2024
e76a918
Update responses.md
TENIOS Jul 19, 2024
b5db722
Update reverb.md
TENIOS Jul 19, 2024
a0db209
Update routing.md
TENIOS Jul 19, 2024
ee5cb7b
Update sail.md
TENIOS Jul 19, 2024
705fa06
Update sanctum.md
TENIOS Jul 19, 2024
c670d90
Update scheduling.md
TENIOS Jul 19, 2024
0f7d952
Update scout.md
TENIOS Jul 19, 2024
1f636fb
Update seeding.md
TENIOS Jul 19, 2024
185ee79
Update session.md
TENIOS Jul 19, 2024
aa67b61
Update socialite.md
TENIOS Jul 19, 2024
314a338
Update strings.md
TENIOS Jul 19, 2024
60328a5
Update telescope.md
TENIOS Jul 19, 2024
bb0fdfc
Update testing.md
TENIOS Jul 19, 2024
c8aaea2
Update upgrade.md
TENIOS Jul 19, 2024
0f79b35
Update urls.md
TENIOS Jul 19, 2024
213c70a
Update valet.md
TENIOS Jul 19, 2024
b775558
Update validation.md
TENIOS Jul 19, 2024
03c7bfe
Update verification.md
TENIOS Jul 19, 2024
fc56d41
Update views.md
TENIOS Jul 19, 2024
aa5b6b1
Update vite.md
TENIOS Jul 19, 2024
06fdf6e
Remove backslash
TENIOS Jul 19, 2024
57e331c
Update ellipses
TENIOS Jul 19, 2024
fc9bc39
Merge remote-tracking branch 'upstream/11.x' into improve-code-format
TENIOS Jul 22, 2024
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
670 changes: 390 additions & 280 deletions artisan.md

Large diffs are not rendered by default.

604 changes: 340 additions & 264 deletions authentication.md

Large diffs are not rendered by default.

716 changes: 393 additions & 323 deletions authorization.md

Large diffs are not rendered by default.

1,846 changes: 1,100 additions & 746 deletions billing.md

Large diffs are not rendered by default.

424 changes: 233 additions & 191 deletions blade.md

Large diffs are not rendered by default.

488 changes: 270 additions & 218 deletions broadcasting.md

Large diffs are not rendered by default.

326 changes: 193 additions & 133 deletions cache.md

Large diffs are not rendered by default.

1,009 changes: 596 additions & 413 deletions cashier-paddle.md

Large diffs are not rendered by default.

3,479 changes: 1,956 additions & 1,523 deletions collections.md

Large diffs are not rendered by default.

54 changes: 33 additions & 21 deletions configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,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 @@ -102,19 +104,23 @@ 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]
> The current application environment detection can be overridden by defining a server-level `APP_ENV` environment variable.
Expand Down Expand Up @@ -188,28 +194,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 Down
92 changes: 51 additions & 41 deletions console-tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,41 +33,47 @@ 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:

```php tab=Pest
test('console command', function () {
$this->artisan('question')
->expectsQuestion('What is your name?', 'Taylor Otwell')
->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);
->expectsQuestion('What is your name?', 'Taylor Otwell')
->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);
});
```

Expand All @@ -78,11 +84,11 @@ test('console command', function () {
public function test_console_command(): void
{
$this->artisan('question')
->expectsQuestion('What is your name?', 'Taylor Otwell')
->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);
->expectsQuestion('What is your name?', 'Taylor Otwell')
->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);
}
```

Expand All @@ -91,8 +97,8 @@ You may also assert that a console command does not generate any output using th
```php tab=Pest
test('console command', function () {
$this->artisan('example')
->doesntExpectOutput()
->assertExitCode(0);
->doesntExpectOutput()
->assertExitCode(0);
});
```

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

Expand All @@ -113,8 +119,8 @@ The `expectsOutputToContain` and `doesntExpectOutputToContain` methods may be us
```php tab=Pest
test('console command', function () {
$this->artisan('example')
->expectsOutputToContain('Taylor')
->assertExitCode(0);
->expectsOutputToContain('Taylor')
->assertExitCode(0);
});
```

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

Expand All @@ -135,23 +141,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, 'taylor@example.com'],
[2, 'abigail@example.com'],
]);
```php
$this->artisan('users:all')
->expectsTable([
'ID',
'Email',
], [
[1, 'taylor@example.com'],
[2, 'abigail@example.com'],
]);
```

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