This repository contains a Laravel 10 with JWT authentication boilerplate using the tymon/jwt-auth package, inspired by the Laravel Breeze package (API stack).
We created a dedicated frontend using Next.js, Tailwind CSS and NextAuth. You can find the repository here.
- JWT authentication (login, register, password reset, email verification)
- Profile updating
- Password changing
- Tests (using Pest)
- Laravel Telescope (disabled by default)
Note: the application does not have a
package.json
since this project purely a REST API that will not use any JavaScript or asset builders such as Vite.
cp .env.example .env
composer install
php artisan jwt:secret
(generate a secret key that will be used to sign your tokens)php artisan migrate:fresh --seed
In order to list all the users in the database, you can run php artisan user:list
. By default, a user with the
'[email protected]' email will be seeded.
In order to authenticate, you have to log in using valid credentials. User data and an access token will be returned. You can use this access token to do subsequent requests to the API.
The access token has a TTL of 1 hour until it expires. The access token should be refreshed within this time window to avoid becoming unauthenticated.
The access token can be refreshed for two weeks. After that, the user has to log in again.
This boilerplate comes with Laravel Telescope installed. You can access the
Telescope dashboard at the /telescope
URL (prefixed with your local URL).
This project uses Larastan. You
can run the static analysis using ./vendor/bin/phpstan analyse
. Important note: a resource class requires a @mixin
annotation so that PHPStan knows what model the resource is using.
This project uses Husky to run Larastan, Pint and Pest before pushing to the repository.
This boilerplate comes with Pest as its testing framework. In order to run the tests,
run ./vendor/bin/pest
.
Feel free to open a pull request if you want to contribute to this project. All contributions / suggestions are welcome ✨
This project is open-sourced software licensed under the MIT license.