Skip to content

Commit 1ab9932

Browse files
authored
[12.x] use fenced code blocks (#10172)
* use fenced code blocks - better syntax highlighting - easier copy/pasting of code examples - consistency throughout docs block * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip
1 parent 5496409 commit 1ab9932

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+25389
-18768
lines changed

artisan.md

+390-280
Large diffs are not rendered by default.

authentication.md

+339-263
Large diffs are not rendered by default.

authorization.md

+393-323
Large diffs are not rendered by default.

billing.md

+1,076-732
Large diffs are not rendered by default.

blade.md

+238-194
Large diffs are not rendered by default.

broadcasting.md

+263-211
Large diffs are not rendered by default.

cache.md

+216-150
Large diffs are not rendered by default.

cashier-paddle.md

+596-413
Large diffs are not rendered by default.

collections.md

+1,991-1,559
Large diffs are not rendered by default.

configuration.md

+33-21
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,9 @@ APP_NAME="My Application"
9797

9898
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:
9999

100-
'debug' => env('APP_DEBUG', false),
100+
```php
101+
'debug' => env('APP_DEBUG', false),
102+
```
101103

102104
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.
103105

@@ -106,19 +108,23 @@ The second value passed to the `env` function is the "default value". This value
106108

107109
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):
108110

109-
use Illuminate\Support\Facades\App;
111+
```php
112+
use Illuminate\Support\Facades\App;
110113

111-
$environment = App::environment();
114+
$environment = App::environment();
115+
```
112116

113117
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:
114118

115-
if (App::environment('local')) {
116-
// The environment is local
117-
}
119+
```php
120+
if (App::environment('local')) {
121+
// The environment is local
122+
}
118123

119-
if (App::environment(['local', 'staging'])) {
120-
// The environment is either local OR staging...
121-
}
124+
if (App::environment(['local', 'staging'])) {
125+
// The environment is either local OR staging...
126+
}
127+
```
122128

123129
> [!NOTE]
124130
> The current application environment detection can be overridden by defining a server-level `APP_ENV` environment variable.
@@ -192,28 +198,34 @@ php artisan env:decrypt --force
192198

193199
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:
194200

195-
use Illuminate\Support\Facades\Config;
201+
```php
202+
use Illuminate\Support\Facades\Config;
196203

197-
$value = Config::get('app.timezone');
204+
$value = Config::get('app.timezone');
198205

199-
$value = config('app.timezone');
206+
$value = config('app.timezone');
200207

201-
// Retrieve a default value if the configuration value does not exist...
202-
$value = config('app.timezone', 'Asia/Seoul');
208+
// Retrieve a default value if the configuration value does not exist...
209+
$value = config('app.timezone', 'Asia/Seoul');
210+
```
203211

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

206-
Config::set('app.timezone', 'America/Chicago');
214+
```php
215+
Config::set('app.timezone', 'America/Chicago');
207216

208-
config(['app.timezone' => 'America/Chicago']);
217+
config(['app.timezone' => 'America/Chicago']);
218+
```
209219

210220
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:
211221

212-
Config::string('config-key');
213-
Config::integer('config-key');
214-
Config::float('config-key');
215-
Config::boolean('config-key');
216-
Config::array('config-key');
222+
```php
223+
Config::string('config-key');
224+
Config::integer('config-key');
225+
Config::float('config-key');
226+
Config::boolean('config-key');
227+
Config::array('config-key');
228+
```
217229

218230
<a name="configuration-caching"></a>
219231
## Configuration Caching

console-tests.md

+33-23
Original file line numberDiff line numberDiff line change
@@ -33,30 +33,36 @@ public function test_console_command(): void
3333

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

36-
$this->artisan('inspire')->assertNotExitCode(1);
36+
```php
37+
$this->artisan('inspire')->assertNotExitCode(1);
38+
```
3739

3840
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:
3941

40-
$this->artisan('inspire')->assertSuccessful();
42+
```php
43+
$this->artisan('inspire')->assertSuccessful();
4144

42-
$this->artisan('inspire')->assertFailed();
45+
$this->artisan('inspire')->assertFailed();
46+
```
4347

4448
<a name="input-output-expectations"></a>
4549
## Input / Output Expectations
4650

4751
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:
4852

49-
Artisan::command('question', function () {
50-
$name = $this->ask('What is your name?');
53+
```php
54+
Artisan::command('question', function () {
55+
$name = $this->ask('What is your name?');
5156

52-
$language = $this->choice('Which language do you prefer?', [
53-
'PHP',
54-
'Ruby',
55-
'Python',
56-
]);
57+
$language = $this->choice('Which language do you prefer?', [
58+
'PHP',
59+
'Ruby',
60+
'Python',
61+
]);
5762

58-
$this->line('Your name is '.$name.' and you prefer '.$language.'.');
59-
});
63+
$this->line('Your name is '.$name.' and you prefer '.$language.'.');
64+
});
65+
```
6066

6167
You may test this command with the following test:
6268

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

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

168-
$this->artisan('module:import')
169-
->expectsConfirmation('Do you really wish to run this command?', 'no')
170-
->assertExitCode(1);
174+
```php
175+
$this->artisan('module:import')
176+
->expectsConfirmation('Do you really wish to run this command?', 'no')
177+
->assertExitCode(1);
178+
```
171179

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

175183
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:
176184

177-
$this->artisan('users:all')
178-
->expectsTable([
179-
'ID',
180-
'Email',
181-
], [
182-
183-
184-
]);
185+
```php
186+
$this->artisan('users:all')
187+
->expectsTable([
188+
'ID',
189+
'Email',
190+
], [
191+
192+
193+
]);
194+
```
185195

186196
<a name="console-events"></a>
187197
## Console Events

0 commit comments

Comments
 (0)