Laravelのartisanコマンドでルートを検索する（オプションまとめ）

# 概要

業務内で、Laravelで書かれているソースコードを読んでいる時に、ルーティングを効率的に検索する必要に迫られることがあります。ですので、オプションを使って効率的に検索する方法をまとめてみました。

## ルート一覧の表示方法

```comandline
php artisan route:list
```


## ルートをパスから探す

```
php artisan route:list --path==api/user/like
```
```
+--------+--------+---------------+------+----------------------------------------------+------------+
| Domain | Method | URI           | Name | Action                                       | Middleware |
+--------+--------+---------------+------+----------------------------------------------+------------+
|        | POST   | api/user/like |      | App\Http\Controllers\LikeApiController@store | api        |
+--------+--------+---------------+------+----------------------------------------------+------------+
```
## ルートを名前から探す

```
php artisan route:list --name==user
```
```
+--------+----------+------------+-------------+--------------------------------------------+------------+
| Domain | Method   | URI        | Name        | Action                                     | Middleware |
+--------+----------+------------+-------------+--------------------------------------------+------------+
|        | POST     | update     | user.update | App\Http\Controllers\UserController@update | web        |
|        | GET|HEAD | {userName} | user.index  | App\Http\Controllers\UserController@index  | web        |
+--------+----------+------------+-------------+--------------------------------------------+------------+

```
## ルートをHTTPメソッドから探す

```
php artisan route:list --method=delete
```
```
+--------+--------+-------------------------------+-----------------------+------------------------------------------------------+------------------------------------------------------+
| Domain | Method | URI                           | Name                  | Action                                               | Middleware                                           |
+--------+--------+-------------------------------+-----------------------+------------------------------------------------------+------------------------------------------------------+
|        | DELETE | _debugbar/cache/{key}/{tags?} | debugbar.cache.delete | Barryvdh\Debugbar\Controllers\CacheController@delete | Barryvdh\Debugbar\Middleware\DebugbarEnabled,Closure |
|        | DELETE | delete/{delete}               |                       | App\Http\Controllers\PostController@delete           | web                                                  |
+--------+--------+-------------------------------+-----------------------+------------------------------------------------------+------------------------------------------------------+
```

## 複合検索も可能
```
php artisan route:list --method=post --name=like --path=unlike
```

```
+--------+--------+---------------------------+--------------+---------------------------------------------+------------+
| Domain | Method | URI                       | Name         | Action                                      | Middleware |
+--------+--------+---------------------------+--------------+---------------------------------------------+------------+
|        | POST   | user/{user}/unlike/{post} | like.destroy | App\Http\Controllers\LikeController@destroy | web        |
+--------+--------+---------------------------+--------------+---------------------------------------------+------------+

```
##逆順で表示
```
php artisan route:list --method=DELETE -r
```
## ソートの方法
```
php artisan route:list --method=DELETE --sort=name
```