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
Copy file name to clipboardExpand all lines: original-en/configuration.md
+4-6Lines changed: 4 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -310,13 +310,11 @@ When accessing this hidden route, you will then be redirected to the `/` route o
310
310
311
311
By default, Laravel determines if your application is in maintenance mode using a file-based system. This means to activate maintenance mode, the `php artisan down` command has to be executed on each server hosting your application.
312
312
313
-
Alternatively, Laravel offers a cache-based method for handling maintenance mode. This method requires running the `php artisan down` command on just one server. To use this approach, modify the "driver" setting in the `config/app.php` file of your application to `cache`. Then, select a cache `store` that is accessible by all your servers. This ensures the maintenance mode status is consistently maintained across every server:
313
+
Alternatively, Laravel offers a cache-based method for handling maintenance mode. This method requires running the `php artisan down` command on just one server. To use this approach, modify the maintenance mode variables in your application's `.env` file. You should select a cache `store` that is accessible by all of your servers. This ensures the maintenance mode status is consistently maintained across every server:
@@ -312,34 +312,38 @@ Route::get('/user', function (#[CurrentUser] User $user) {
312
312
313
313
You can create your own contextual attributes by implementing the `Illuminate\Contracts\Container\ContextualAttribute` contract. The container will call your attribute's `resolve` method, which should resolve the value that should be injected into the class utilizing the attribute. In the example below, we will re-implement Laravel's built-in `Config` attribute:
314
314
315
-
<?php
315
+
```php
316
+
<?php
316
317
317
-
namespace App\Attributes;
318
+
namespace App\Attributes;
318
319
319
-
use Illuminate\Contracts\Container\ContextualAttribute;
320
+
use Attribute;
321
+
use Illuminate\Contracts\Container\Container;
322
+
use Illuminate\Contracts\Container\ContextualAttribute;
320
323
321
-
#[Attribute(Attribute::TARGET_PARAMETER)]
322
-
class Config implements ContextualAttribute
324
+
#[Attribute(Attribute::TARGET_PARAMETER)]
325
+
class Config implements ContextualAttribute
326
+
{
327
+
/**
328
+
* Create a new attribute instance.
329
+
*/
330
+
public function __construct(public string $key, public mixed $default = null)
323
331
{
324
-
/**
325
-
* Create a new attribute instance.
326
-
*/
327
-
public function __construct(public string $key, public mixed $default = null)
@@ -349,8 +353,8 @@ Sometimes you may have a class that receives some injected classes, but also nee
349
353
use App\Http\Controllers\UserController;
350
354
351
355
$this->app->when(UserController::class)
352
-
->needs('$variableName')
353
-
->give($value);
356
+
->needs('$variableName')
357
+
->give($value);
354
358
355
359
Sometimes a class may depend on an array of [tagged](#tagging) instances. Using the `giveTagged` method, you may easily inject all of the container bindings with that tag:
356
360
@@ -397,24 +401,24 @@ Occasionally, you may have a class that receives an array of typed objects using
397
401
Using contextual binding, you may resolve this dependency by providing the `give` method with a closure that returns an array of resolved `Filter` instances:
398
402
399
403
$this->app->when(Firewall::class)
400
-
->needs(Filter::class)
401
-
->give(function (Application $app) {
402
-
return [
403
-
$app->make(NullFilter::class),
404
-
$app->make(ProfanityFilter::class),
405
-
$app->make(TooLongFilter::class),
406
-
];
407
-
});
404
+
->needs(Filter::class)
405
+
->give(function (Application $app) {
406
+
return [
407
+
$app->make(NullFilter::class),
408
+
$app->make(ProfanityFilter::class),
409
+
$app->make(TooLongFilter::class),
410
+
];
411
+
});
408
412
409
413
For convenience, you may also just provide an array of class names to be resolved by the container whenever `Firewall` needs `Filter` instances:
0 commit comments