/breeze-api

Laravel Breeze API template application based on Sail

Primary LanguagePHPMIT LicenseMIT

Laravel Logo

Laravel Breeze API template

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:

Prerequisites

To work with this project you will also need to install the following software:

Features

  • Laravel 11
  • Breeze API with Sanctum
  • Laravel Pint code formatter
  • Larastan static analysis rules
  • IDE helper for Laravel (Stubs generation)

Installation

  1. Clone the repository:
git clone https://github.com/manchenkoff/breeze-api
  1. Build the project and install dependencies:
task build
  1. Start the project:
task start

Once the project is started, you can access it at http://localhost.

Development

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.

Production

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