An opinionated starter kit for RESTful API development with Laravel Sanctum.
- Laravel ^12
- PHP ^8.2
- Login
- Registration
- Email verification
- Password reset
- Users management
- API Documentation with Scribe
- API versioning
git clone https://github.com/eliseekn/laravel-sanctum-starter-kit.git project-name
cd project-name && composer install
cp .env.example .env
- Add front-end url in the .env file
FRONTEND_URL=http://localhost
- Edit the boot method in AppServiceProvider.php file to ensure that your front-end endpoints are correct
VerifyEmail::createUrlUsing(function ($notifiable) {
// $url is directly set as the API endpoint for email verification
// see 'verification.verify' route
$url = URL::temporarySignedRoute(
'verification.verify',
now()->addMinutes(config('auth.verification.expire', 60)), [
'id' => $notifiable->getKey(),
'hash' => sha1($notifiable->getEmailForVerification()),
]
);
return config('app.frontend_url').'/email-verification?url='.urlencode($url);
});
ResetPassword::createUrlUsing(
fn ($user, string $token) => config('app.frontend_url').'/reset-password?email=' . $user->email . '&token='.$token
);
- Setup your mail server
php artisan test
Run php artisan serve
and open http://127.0.0.1:8000/docs
in your web browser.