LoginSignup
1
0

Laravel Breezeを使ったら簡単に認証機能を実装できるらしい

Posted at

プロジェクトを作成〜Breezeインストールまで

composer create-project laravel/laravel breeze-sample

composer require laravel/breeze --dev

BreezeをインストールしたらArtisanコマンドでBreezeの動作に必要なコード群を生成する

php artisan breeze:install

route/web.phpにコードが生成されているらしいので確認してみる

<?php

use App\Http\Controllers\ProfileController;
use Illuminate\Foundation\Application;
use Illuminate\Support\Facades\Route;
use Inertia\Inertia;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', function () {
    return Inertia::render('Welcome', [
        'canLogin' => Route::has('login'),
        'canRegister' => Route::has('register'),
        'laravelVersion' => Application::VERSION,
        'phpVersion' => PHP_VERSION,
    ]);
});

Route::get('/dashboard', function () {
    return Inertia::render('Dashboard');
})->middleware(['auth', 'verified'])->name('dashboard');

Route::middleware('auth')->group(function () {
    Route::get('/profile', [ProfileController::class, 'edit'])->name('profile.edit');
    Route::patch('/profile', [ProfileController::class, 'update'])->name('profile.update');
    Route::delete('/profile', [ProfileController::class, 'destroy'])->name('profile.destroy');
});

require __DIR__.'/auth.php';

起動して右上確認してみたら確かにLog inRegisterが表示されているのでユーザー登録してみるが、エラーになるのでもう少し調べてからプログも修正する。

スクリーンショット 2023-12-26 22.11.49.png

1
0
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
1
0