Scaffold Laravel project with authentication and API
✓Works with OpenClaudeYou are a Laravel developer. The user wants to scaffold a new Laravel project with built-in authentication and API routes configured.
What to check first
- Ensure PHP 8.1+ is installed:
php --version - Verify Composer is installed:
composer --version - Check that you have write permissions in your project directory
Steps
- Create a new Laravel project using Composer:
composer create-project laravel/laravel my-app - Navigate into the project directory:
cd my-app - Install Laravel Breeze for authentication scaffolding:
composer require laravel/breeze --dev - Publish the Breeze scaffolding with API support:
php artisan breeze:install --api - Run migrations to set up authentication tables:
php artisan migrate - Start the development server:
php artisan serve - Verify the API routes are registered in
routes/api.phpand authentication middleware is applied - Test authentication by making a POST request to
/api/loginwith test credentials
Code
<?php
// routes/api.php - After running breeze:install --api
use App\Http\Controllers\Auth\AuthenticatedSessionController;
use App\Http\Controllers\Auth\RegisteredUserController;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
Route::post('/register', [RegisteredUserController::class, 'store']);
Route::post('/login', [AuthenticatedSessionController::class, 'store']);
Route::middleware('auth:sanctum')->group(function () {
Route::get('/user', function (Request $request) {
return $request->user();
});
Route::post('/logout', [AuthenticatedSessionController::class, 'destroy']);
});
// Example protected API resource
Route::middleware('auth:sanctum')->group(function () {
Route::get('/posts', function () {
return response()->json([
'posts' => [
['id' => 1, 'title' => 'First Post'],
['id' => 2, 'title' => 'Second Post'],
]
]);
});
});
Pitfalls
- Laravel Breeze scaffolds authentication UI by default; use
--apiflag specifically to enable Sanctum token authentication instead of session-based auth - Running
php artisan migratebefore setting up the database connection in.envwill fail—configureDB_CONNECTION,DB_DATABASE, and credentials first - Sanctum tokens are tied to the
apiguard; ensure your middleware usesauth:sanctumnot justauthfor API routes - The
breeze:installcommand overwrites existing route files; back uproutes/api.phpandroutes/web.phpif they contain custom code
Common Pitfalls
- Treating this skill as a one-shot solution — most workflows need iteration and verification
- Skipping the verification steps — you don't know it worked until you measure
- Applying this skill without understanding the underlying problem — read the related docs first
When NOT to Use This Skill
- When a simpler manual approach would take less than 10 minutes
- On critical production systems without testing in staging first
- When you don't have permission or authorization to make these changes
How to Verify It Worked
- Run the verification steps documented above
- Compare the output against your expected baseline
- Check logs for any warnings or errors — silent failures are the worst kind
Production Considerations
- Test in staging before deploying to production
- Have a rollback plan — every change should be reversible
- Monitor the affected systems for at least 24 hours after the change
Related Laravel Skills
Other Claude Code skills in the same category — free to download.
Laravel Eloquent
Write Eloquent models with relationships and scopes
Laravel Migration
Create database migrations with foreign keys and indexes
Laravel API Resource
Build REST API with resources and form requests
Laravel Queue
Set up job queues with Redis/database drivers
Laravel Testing
Write feature and unit tests with PHPUnit and Pest
Laravel Livewire
Build reactive components with Laravel Livewire
Laravel Nova
Customize Laravel Nova admin panels
Want a Laravel skill personalized to YOUR project?
This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.