laravel12.laravel_031
最終投稿日:2026年3月1日
export default defineConfig({
plugins: [
laravel({
input: ['resources/css/app.css', 'resources/js/app.js'],
refresh: true,
}),
tailwindcss(),
],
server: {
watch: {
ignored: ['**/storage/framework/views/**'],
},
},
build: {
outDir: 'C:\\~\\laravel_12\\laravel_12\\build',
emptyOutDir: true,
},
});
C:\~\laravel_12>composer require laravel/ui
./composer.json has been updated
Running composer update laravel/ui
Loading composer repositories with package information
Updating dependencies
Lock file operations: 1 install, 0 updates, 0 removals
- Locking laravel/ui (v4.6.1)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
- Downloading laravel/ui (v4.6.1)
- Installing laravel/ui (v4.6.1): Extracting archive
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
[37;44m INFO [39;49m Discovering packages.
laravel/pail [90m. [39m [90m. [39m [90m. [39m [90m. [39m...
~ 省略 ~
82 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
[37;44m INFO [39;49m No publishable resources for tag [1m[laravel-assets] [22m.
No security vulnerability advisories found.
Using version ^4.6 for laravel/ui
C:\~\laravel_12>
C:\~\laravel_12>php artisan ui vue --auth
The [auth/login.blade.php] view already exists. Do you want to replace it? (yes/no) [no]
The [auth/passwords/confirm.blade.php] view already exists. Do you want to replace it? (yes/no) [no]
The [auth/passwords/email.blade.php] view already exists. Do you want to replace it? (yes/no) [no]
The [auth/passwords/reset.blade.php] view already exists. Do you want to replace it? (yes/no) [no]
The [auth/register.blade.php] view already exists. Do you want to replace it? (yes/no) [no]
The [auth/verify.blade.php] view already exists. Do you want to replace it? (yes/no) [no]
The [home.blade.php] view already exists. Do you want to replace it? (yes/no) [no]
The [layouts/app.blade.php] view already exists. Do you want to replace it? (yes/no) [no]
The [HomeController.php] file already exists. Do you want to replace it? (yes/no) [yes]
The [Controller.php] file already exists. Do you want to replace it? (yes/no) [yes]
INFO Authentication scaffolding generated successfully.
INFO Vue scaffolding installed successfully.
WARN Please run [npm install && npm run dev] to compile your fresh scaffolding.
C:\~\laravel_12>
Laravelが要求する「public」ディレクトリ直下に『build』ディレクトリが作成されてますか?
「public」は公開ディレクトリですので、Apacheで設定している【WebRoot】か、更に下層へ設置する必要があります。
本解説では「public」は「laravel_12」へリネームし、[WebRoot]直下に設置しています。
※詳しくは『ディレクトリ構造を変更する』参照
Laravelは「public」ディレクトリを「artisan」がある階層から探そうとします。
エラーになる場合は、今一度自信のディレクトリ構造を見直してください。
<?php
use Illuminate\Support\Facades\Route;
Auth::routes();
Route::get('/home', [App\Http\Controllers\HomeController::class, 'index'])->name('home');
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class HomeController extends Controller {
public function __construct() {
$this->middleware('auth');
}
public function index() {
return view('home');
}
}
Auth::routes();
Route::group(['middleware' => 'auth'], function(){
Route::get('/home', [App\Http\Controllers\HomeController::class, 'index'])->name('home');
});
<div class="row mb-3">
<label for="name" class="col-md-4 col-form-label text-md-end">{{ __('Name') }}</label>
<div class="col-md-6">
<input id="name" type="text" class="form-control @error('name') is-invalid @enderror" name="name" value="{{ old('name') }}" required autocomplete="name" autofocus>
@error('name')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
public function username() {
return 'name';
}
protected function validator(array $data) {
return Validator::make($data, [
'name' => ['required', 'string', 'max:255', 'unique:users'],
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
'password' => ['required', 'string', 'min:8', 'confirmed'],
]);
}
laravel/ui は、Laravel 6 以降で使われる、認証用のUIや Bootstrap / Vue / React ベースのフロントエンドスカフォールドを提供する公式パッケージです。