0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Laravel9 artisanコマンド 一覧

Last updated at Posted at 2022-11-12

最新のLTSであるLaravel9で使える artisan コマンドを、具体的なサンプル付きでまとめました。
よかったらストックしていってください!(・∀・)

※全て実際に使用して試しております。(随時更新)

ルーティングの一覧を作成

// ルーティングの一覧を、ターミナルでパパっと確認したい時
% php artisan r:l     
(% php artisan route:list   も可)                            
% php artisan r:l    
                               

  GET|HEAD   / .............................................................................................................................. 
  POST       _ignition/execute-solution ....................... ignition.executeSolution › Spatie\LaravelIgnition › ExecuteSolutionController
  GET|HEAD   _ignition/health-check ................................... ignition.healthCheck › Spatie\LaravelIgnition › HealthCheckController
  POST       _ignition/update-config ................................ ignition.updateConfig › Spatie\LaravelIgnition › UpdateConfigController
  GET|HEAD   api/user ....................................................................................................................... 
  GET|HEAD   confirm-password .................................................... password.confirm › Auth\ConfirmablePasswordController@show
  POST       confirm-password ...................................................................... Auth\ConfirmablePasswordController@store
  GET|HEAD   dashboard ............................................................................................................ dashboard
  POST       email/verification-notification ......................... verification.send › Auth\EmailVerificationNotificationController@store
  GET|HEAD   forgot-password ..................................................... password.request › Auth\PasswordResetLinkController@create
  POST       forgot-password ........................................................ password.email › Auth\PasswordResetLinkController@store
  GET|HEAD   login ....................................................................... login › Auth\AuthenticatedSessionController@create
  POST       login ................................................................................ Auth\AuthenticatedSessionController@store
  POST       logout .................................................................... logout › Auth\AuthenticatedSessionController@destroy
  GET|HEAD   register ....................................................................... register › Auth\RegisteredUserController@create
  POST       register ................................................................................... Auth\RegisteredUserController@store
  POST       reset-password .............................................................. password.update › Auth\NewPasswordController@store
  GET|HEAD   reset-password/{token} ...................................................... password.reset › Auth\NewPasswordController@create
  GET|HEAD   sanctum/csrf-cookie .......................................... sanctum.csrf-cookie › Laravel\Sanctum › CsrfCookieController@show
  GET|HEAD   verify-email ............................................. verification.notice › Auth\EmailVerificationPromptController@__invoke
  GET|HEAD   verify-email/{id}/{hash} ............................................. verification.verify › Auth\VerifyEmailController@__invoke

                                                                                                                          Showing [21] routes
    

ルーティングのキャッシュ削除

% php artisan route:cache

// <補足>
// ルーティングが反映されない時にキャッシュを削除
//(Laravel9ではルートを変更した場合これをしないと反映されないケースがある)                     
% php artisan route:cache                                                

   INFO  Routes cached successfully.        

モデルやマイグレーション生成

(その他、ファクトリ、シーダ、ポリシー、コントローラ、フォームリクエスト)

# モデルのみ生成
% php artisan make:model Egg 

# モデル + マイグレーション生成
% php artisan make:model Egg -m

# モデルとマイグレーション、ファクトリ、シーダ、およびコントローラを生成
php artisan make:model Egg -mfsc

# モデルとマイグレーション、ファクトリ、シーダ、ポリシー、コントローラ、フォームリクエストを生成する短縮形
php artisan make:model Egg --all
                    
# 具体例 ( HomeSlideは、適当なモデル名)
% php artisan make:model HomeSlide -m 

   INFO  Model [app/Models/HomeSlide.php] created successfully.  

   INFO  Created migration [2022_11_20_050141_create_home_slides_table].         

コントローラー作成

% php artisan make:controller Egg

# ディレクトリを挟みたい(もしくは自動生成したい)場合
php artisan make:controller Home/Egg                   
% php artisan make:controller Home/HomeSliderController 

   INFO  Controller [app/Http/Controllers/Home/HomeSliderController.php] created successfully.         
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?