Laravel Breeze をインストールすると簡単にログイン機能を追加することが可能です。以下、Laravel Breeze v1.18.0 をインストールした際のメモ。(*Laravel Sail 利用)
Laravel Breeze インストール
パッケージ追加
sail composer require laravel/breeze --dev
上記のコマンドを実行すると以下のようにインストールが開始されます。
% sail composer require laravel/breeze --dev Info from https://repo.packagist.org: #StandWithUkraine ./composer.json has been updated Running composer update laravel/breeze Loading composer repositories with package information Updating dependencies Lock file operations: 1 install, 0 updates, 0 removals - Locking laravel/breeze (v1.18.0) Writing lock file Installing dependencies from lock file (including require-dev) Package operations: 1 install, 0 updates, 0 removals - Downloading laravel/breeze (v1.18.0) - Installing laravel/breeze (v1.18.0): Extracting archive Generating optimized autoload files > Illuminate\Foundation\ComposerScripts::postAutoloadDump > @php artisan package:discover --ansi INFO Discovering packages. laravel/breeze .......................... DONE laravel/sail ............................ DONE laravel/sanctum ......................... DONE laravel/tinker .......................... DONE nesbot/carbon ........................... DONE nunomaduro/collision .................... DONE nunomaduro/termwind ..................... DONE spatie/laravel-ignition ................. DONE 80 packages you are using are looking for funding. Use the `composer fund` command to find out more! > @php artisan vendor:publish --tag=laravel-assets --ansi --force INFO No publishable resources for tag [laravel-assets]. No security vulnerability advisories found Using version ^1.18 for laravel/breeze
ログイン機能に必要なファイルを生成
sail artisan breeze:install
Bladeスタックを選択してインストールを行いました。
% sail artisan breeze:install Which stack would you like to install? blade ....................0 react ....................1 vue ......................2 api ......................3 ❯ 0 Would you like to install dark mode support? (yes/no) [no] ❯ yes Would you prefer Pest tests instead of PHPUnit? (yes/no) [no] ❯ yes ./composer.json has been updated Running composer update pestphp/pest pestphp/pest-plugin-laravel Loading composer repositories with package information Updating dependencies Lock file operations: 3 installs, 0 updates, 0 removals - Locking pestphp/pest (v1.22.3) - Locking pestphp/pest-plugin (v1.1.0) - Locking pestphp/pest-plugin-laravel (v1.4.0) Writing lock file Installing dependencies from lock file (including require-dev) Package operations: 3 installs, 0 updates, 0 removals - Downloading pestphp/pest-plugin (v1.1.0) - Downloading pestphp/pest (v1.22.3) - Downloading pestphp/pest-plugin-laravel (v1.4.0) 0/3 [>---------------------------] 0% 1/3 [=========>------------------] 33% 3/3 [============================] 100% - Installing pestphp/pest-plugin (v1.1.0): Extracting archive - Installing pestphp/pest (v1.22.3): Extracting archive - Installing pestphp/pest-plugin-laravel (v1.4.0): Extracting archive 0/2 [>---------------------------] 0% 1/2 [==============>-------------] 50% 2/2 [============================] 100% Generating optimized autoload files > Illuminate\Foundation\ComposerScripts::postAutoloadDump > @php artisan package:discover --ansi INFO Discovering packages. laravel/breeze ........................................................ DONE laravel/sail .......................................................... DONE laravel/sanctum ....................................................... DONE laravel/tinker ........................................................ DONE nesbot/carbon ......................................................... DONE nunomaduro/collision .................................................. DONE nunomaduro/termwind ................................................... DONE pestphp/pest .......................................................... DONE spatie/laravel-ignition ............................................... DONE 83 packages you are using are looking for funding. Use the `composer fund` command to find out more! > @php artisan vendor:publish --tag=laravel-assets --ansi --force INFO No publishable resources for tag [laravel-assets]. No security vulnerability advisories found added 93 packages, and audited 94 packages in 3m 20 packages are looking for funding run `npm fund` for details found 0 vulnerabilities npm notice npm notice New minor version of npm available! 9.2.0 -> 9.3.1 npm notice Changelog: https://github.com/npm/cli/releases/tag/v9.3.1 npm notice Run npm install -g npm@9.3.1 to update! npm notice > build > vite build vite v4.0.4 building for production... ✓ 51 modules transformed. public/build/manifest.json 0.26 kB public/build/assets/app-063f5526.css 30.28 kB │ gzip: 5.66 kB public/build/assets/app-fe5e93e3.js 141.71 kB │ gzip: 52.19 kB INFO Breeze scaffolding installed successfully.
マイグレーション実行
sail artisan migrate
マイグレーションを実行していない場合は、上記コマンドを実行します。
% sail artisan migrate INFO Preparing database. Creating migration table .........................................83ms DONE INFO Running migrations. 2014_10_12_000000_create_users_table ............................122ms DONE 2014_10_12_100000_create_password_resets_table ...................97ms DONE 2019_08_19_000000_create_failed_jobs_table .......................68ms DONE 2019_12_14_000001_create_personal_access_tokens_table ...........110ms DONE
表示確認
Laravel Breeze インストール前
Laravel Breeze インストール後
画面右上に “Log in” / “Register” のリンクが追加されます。
ログイン画面
登録画面
動作環境情報
"macOS Ventura" 13.1 "Docker Desktop" 4.15.0 "Laravel Sail" "Laravel Framework" 9.48.0
コメント