Laravel 10.xのartisanの「make:middleware」コマンドを解説します。
Description
新しいミドルウェアクラスの作成
Usage
php artisan make:middleware [--test] [--pest] [--] <name>
Arguments
引数 | 必須 | 説明 |
---|---|---|
name | 必須 | ミドルウェア名 |
Options
オプション | 省略形 | 必須 | 説明 |
---|---|---|---|
test | - | - | Middlewareに付随するPHPUnitのテストを生成 |
pest | - | - | ミドルウェアに付随するPestテストを生成 |
Examples
no options
php artisan make:middleware Foo
INFO Middleware [app/Http/Middleware/Foo.php] created successfully.
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;
class Foo
{
/**
* Handle an incoming request.
*
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
*/
public function handle(Request $request, Closure $next): Response
{
return $next($request);
}
}
Stub
Option | Stub file name |
---|---|
- | middleware.stub |
Source
10.x
framework/src/Illuminate/Routing/Console/MiddlewareMakeCommand.php at 11.x · laravel/framework
The Laravel Framework. Contribute to laravel/framework development by creating an account on GitHub.
11.x
framework/src/Illuminate/Routing/Console/MiddlewareMakeCommand.php at 11.x · laravel/framework
The Laravel Framework. Contribute to laravel/framework development by creating an account on GitHub.
コメント