Skip to content

Commit 19e30b3

Browse files
committed
feat: update mvc middleware docs
1 parent 15831bc commit 19e30b3

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

src/docs/routing/middleware/mvc.md

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,22 +37,24 @@ This will generate a `LogRequestMiddleware.php` file in the `app/middleware` fol
3737

3838
## Loading Middleware for all routes
3939

40-
All middleware generated using the Console will be automatically registered in the `app/middleware/Middleware.php` file. This file is automatically loaded by Leaf MVC, so any middleware you add to it will be loaded for every route in your application. If you don't want a middleware to be automatically loaded, you can remove it from the `app/middleware/Middleware.php` file.
40+
All middleware generated using the Console will be automatically registered in the `app/routes/index.php` file. This file is automatically loaded by Leaf MVC, so any middleware you add to it will be loaded for every route in your application. If you don't want a middleware to be automatically loaded, you can remove it from the `app/routes/index.php` file.
4141

4242
```php
43-
<?php
44-
45-
namespace App\Middleware;
43+
use App\Middleware\LogRequestMiddleware;
4644

47-
class Middleware
48-
{
49-
public function register()
50-
{
51-
return [
52-
LogRequestMiddleware::class
53-
];
54-
}
55-
}
45+
...
46+
47+
/*
48+
|--------------------------------------------------------------------------
49+
| Set middleware for all routes
50+
|--------------------------------------------------------------------------
51+
|
52+
| You can use app()->use() to load middleware for all
53+
| routes in your application.
54+
|
55+
*/
56+
app()->use(LogRequestMiddleware::class);
57+
app()->use(AnotherMiddleware::class);
5658
```
5759

5860
## Loading Middleware for specific routes

src/docs/security/csrf.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ It is not required to change the secret key, but it is recommended to do so if y
145145

146146
If you have an environment file, you can set the secret key there.
147147

148-
```env
148+
```txt
149149
X_CSRF_SECRET=my-new-secret-key
150150
```
151151

0 commit comments

Comments
 (0)