Open5
Laravel breezeお試し
// Laravel breezeのイストール
composer require laravel/breeze
// composer.json
"require": {
"php": "^8.2",
"laravel/breeze": "^2.2",
//
php artisan breeze:install
┌ Which Breeze stack would you like to install? ───────────────┐
│ Blade with Alpine │
└──────────────────────────────────────────────────────────────┘
┌ Would you like dark mode support? ───────────────────────────┐
│ Yes │
└──────────────────────────────────────────────────────────────┘
┌ Which testing framework do you prefer? ──────────────────────┐
│ Pest │
└──────────────────────────────────────────────────────────────┘
./composer.json has been updated
Running composer update pestphp/pest pestphp/pest-plugin-laravel
Loading composer repositories with package information
Updating dependencies
Nothing to modify in lock file
Writing lock file
Installing dependencies from lock file (including require-dev)
Nothing to install, update or remove
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
maatwebsite/excel ..................................................... DONE
nesbot/carbon ......................................................... DONE
nunomaduro/collision .................................................. DONE
nunomaduro/termwind ................................................... DONE
pestphp/pest-plugin-laravel ........................................... DONE
104 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].
Found 5 security vulnerability advisories affecting 4 packages.
Run "composer audit" for a full list of advisories.
Using version ^3.3 for pestphp/pest
Using version ^3.0 for pestphp/pest-plugin-laravel
INFO Installing and building Node dependencies.
up to date, audited 149 packages in 1s
36 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
> build
> vite build
vite v5.4.8 building for production...
✓ 54 modules transformed.
public/build/manifest.json 0.27 kB │ gzip: 0.15 kB
public/build/assets/app-D0wcDdoZ.css 38.95 kB │ gzip: 6.86 kB
public/build/assets/app-BjCBnTiP.js 79.60 kB │ gzip: 29.66 kB
✓ built in 3.90s
INFO Breeze scaffolding installed successfully.
root@17ca63650972:/var/www/html# ```
Feature | Livewire | Inertia.js |
---|---|---|
Frontend Technology | Uses Blade and minimal JavaScript under the hood. | Uses Vue.js, React, or Svelte for the frontend. |
How It Works | Sends AJAX requests to the server to update the DOM. | Sends JSON responses from the server, rendered by the frontend framework. |
SPA Support | Not a true SPA but offers a dynamic experience. | Creates a full SPA experience with client-side routing. |
Ease of Use | Easier for PHP developers; no need to write JavaScript. | Better for developers familiar with JavaScript frameworks. |
Component Structure | Components are written in PHP and Blade. | Components are written in Vue, React, or Svelte. |
Routing | Uses Laravel’s default routing system. | Uses Laravel’s routing but integrates it with frontend routing. |
State Management | Provides two-way data binding between the backend and frontend. | Uses JavaScript frameworks' built-in state management (e.g., Vuex, Redux). |
SEO | Fully server-side rendered, good for SEO out of the box. | SPA with client-side rendering, may require additional work for SEO. |
Learning Curve | Lower for Laravel/PHP developers. | Higher, especially if you are not familiar with JavaScript frameworks. |
<?php
use App\Http\Controllers\ProfileController;
use Illuminate\Support\Facades\Route;
Route::get('/', function () {
return view('welcome');
});
Route::get('/dashboard', function () {
return view('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';
// ログイン処理の場所
// app/Http/Requests/Auth/LoginRequest.php
/**
* Attempt to authenticate the request's credentials.
*
* @throws \Illuminate\Validation\ValidationException
*/
public function authenticate(): void
{
$this->ensureIsNotRateLimited();
if (! Auth::attempt($this->only('email', 'password'), $this->boolean('remember'))) {
RateLimiter::hit($this->throttleKey());
throw ValidationException::withMessages([
'email' => trans('auth.failed'),
]);
}
RateLimiter::clear($this->throttleKey());
}