innonazarene / sanctum-auth-kit
One-command Laravel Sanctum auth boilerplate (register, login, logout, me, change password, forgot/reset password, email verification) with an AuthController, routes, and Scramble API docs installed automatically.
Requires
- php: ^8.1
- dedoc/scramble: ^0.11|^0.12|^0.13
- laravel/framework: ^10.0|^11.0|^12.0|^13.0
- laravel/sanctum: ^3.3|^4.0
Requires (Dev)
- orchestra/testbench: ^8.0|^9.0|^10.0
- phpunit/phpunit: ^10.0|^11.0
README
One-command Laravel Sanctum auth boilerplate. Installs a full token-based AuthController (register, login, logout, me, change password, forgot/reset password, email verification), wires up the routes, and installs Scramble so your API docs are live at /docs/api — all from a single artisan command.
Requirements
- PHP ^8.1
- Laravel ^10.0 | ^11.0 | ^12.0 | ^13.0
Installation
composer require innonazarene/sanctum-auth-kit php artisan sanctum-auth:install
That single install command will:
- Publish Laravel Sanctum's config and migration.
- Add the
HasApiTokenstrait toApp\Models\User(only if it's not already there). - Publish
App\Http\Controllers\Api\AuthController. - Publish the auth form requests to
App\Http\Requests\Auth:LoginRequestRegisterRequestChangePasswordRequestForgotPasswordRequestResetPasswordRequest
- Publish
routes/auth.phpand require it fromroutes/api.php. - Publish Scramble's config so
/docs/apiserves generated OpenAPI docs for the new endpoints.
Run php artisan migrate afterwards to create the personal_access_tokens table.
Pass --force to overwrite files that already exist:
php artisan sanctum-auth:install --force
Generated endpoints
Routes are published to routes/auth.php and required from routes/api.php, so Laravel's default api route-group prefix applies — every endpoint below is served under /api.
| Method | URI | Auth required | Description |
|---|---|---|---|
| POST | /api/auth/register |
Register + issue a token | |
| POST | /api/auth/login |
Login + issue a token | |
| POST | /api/auth/forgot-password |
Send a password reset link | |
| POST | /api/auth/reset-password |
Reset password via token | |
| GET | /api/auth/verify-email/{id}/{hash} |
signed | Verify email address |
| POST | /api/auth/logout |
✅ | Revoke the current token |
| GET | /api/auth/me |
✅ | Get the authenticated user |
| POST | /api/auth/change-password |
✅ | Change password |
| POST | /api/auth/email/verification-notification |
✅ | Resend verification email |
If routes/api.php doesn't exist yet (a plain Laravel 11+ skeleton doesn't ship one), the installer creates it and registers it in bootstrap/app.php automatically.
All published files are plain Laravel code — edit them freely after installation, this package does not hook into them afterwards.
License
MIT