This repository is a template for Laravel projects based on Sail environment to integrate with the Sanctum authentication.
You can use this project to integrate with one of these frontend applications:
- Breeze Next (React/Next)
- Breeze Nuxt (Vue/Nuxt)
To work with this project you will also need to install the following software:
- Laravel 11
- Breeze API with Sanctum
- Laravel Pint code formatter
- Larastan static analysis rules
- IDE helper for Laravel (Stubs generation)
- Clone the repository:
git clone https://github.com/manchenkoff/breeze-api
- Build the project and install dependencies:
task build
- Start the project:
task start
Once the project is started, you can access it at http://localhost.
To get more details about available commands in taskfile
, run the following command:
task -a
To auto-format your code use task fmt
command and also task lint
to check the code quality by running Larastan checks.
Environment
To make sure that Laravel Sanctum will work on your production instance, make sure that you defined properly the following environment variables:
APP_KEY=base64:your_key_here # Generate a new key using `php artisan key:generate --show`
FRONTEND_URL=https://domain.com # Your frontend Nuxt application URL
SESSION_DOMAIN=.domain.com # Your domain should start with a dot to support all subdomains like www.* or frontend.*
💡 Keep in mind, that SESSION_DOMAIN
is not applicable for localhost
and should not be used during development with the value other than null
.
Multiple apps
If you have multiple frontend applications (e.g. public and admin apps), you can define the SANCTUM_STATEFUL_DOMAINS
environment variable to allow multiple domains to access the same session.
SANCTUM_STATEFUL_DOMAINS=domain.com,backoffice.domain.com,admin.domain.com