【Laravel】便利なコマンド集

Laravel
この記事は約5分で読めます。

 ※Laravel コマンドの備忘録(徐々に追加&更新していきます!

Laravel artisan コマンド

php artisan list

※ Laravel コマンドのリストを表示

> php artisan list

Usage:
  command [options] [arguments]

Options:
  -h, --help            Display help for the given command. When no command is given display help for the list command
  -q, --quiet           Do not output any message
  -V, --version         Display this application version
      --ansi|--no-ansi  Force (or disable --no-ansi) ANSI output
  -n, --no-interaction  Do not ask any interactive question
      --env[=ENV]       The environment the command should run under
  -v|vv|vvv, --verbose  Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
Laravel artisan コマンド

php artisan migrate

※ migrate 失敗時 (DB 接続エラー)

> php artisan migrate

Illuminate\Database\QueryException

SQLSTATE[HY000] [1049] Unknown database 'chartjs_db' (SQL: select * from information_schema.tables where table_schema = chartjs_db and table_name = migrations and table_type = 'BASE TABLE')

php artisan serve

 ※Laravel を localhost でサービス起動

> php artisan serve

Starting Laravel development server: http://127.0.0.1:8000

[Tue Aug  2 22:58:22 2022] PHP 7.4.8 Development Server (http://127.0.0.1:8000) started
[Tue Aug  2 22:58:55 2022] 127.0.0.1:58401 Accepted
[Tue Aug  2 22:58:56 2022] 127.0.0.1:58401 Closing
[Tue Aug  2 22:58:57 2022] 127.0.0.1:58404 Accepted
[Tue Aug  2 22:58:57 2022] 127.0.0.1:58404 [200]: GET /favicon.ico
[Tue Aug  2 22:58:57 2022] 127.0.0.1:58404 Closing
Laravel 起動
Laravel 起動

php artisan route:list

 ※ ルーティングのリストを表示

> php artisan route:list

+--------+----------+---------------------+------+------------------------------------------------------------+------------------------------------------+
| Domain | Method   | URI                 | Name | Action                                                     | Middleware                               |
+--------+----------+---------------------+------+------------------------------------------------------------+------------------------------------------+
|        | GET|HEAD | /                   |      | Closure                                                    | web                                      |
|        | GET|HEAD | api/user            |      | Closure                                                    | api                                      |
|        |          |                     |      |                                                            | App\Http\Middleware\Authenticate:sanctum |