Laravel Airlock Renamed to Sanctum

Laravel Airlock Renamed to Sanctum

Last week the Laravel blog announced that Laravel Airlock needed to change “due to a trademark dispute regarding the name ‘Airlock.'”

The new name is Laravel Sanctum.

You may even be coming here after seeing an airlock package abandonment warning when installing v1.x versions:

Below you can find a few other details on updating your code if you depend on laravel/airlock.

TLDR

You need to find/replace anywhere in your code you find Airlock and airlock to Sanctum and sanctum, respectively.

Steps to Update

Everything feature-wise remains the same, but you’ll need to make a few changes to start using the new repo and drop the abandoned laravel/airlock package. The diff of the documentation page could be helpful to follow along if you need to update existing projects.

The rough steps to change from Airlock involve the following:

  1. Add the laravel/sanctum composer dependency
  2. Either publish the sanctum vendor config or move the existing config/airlock.php config
  3. Find/replace Airlock for Sanctum and airlock for sanctum
    • If you’re using the middleware for a SPA, change Airlock to Sanctum
    • Update any environment configuration for AIRLOCK_STATEFUL_DOMAINS to SANCTUM_STATEFUL_DOMAINS
  4. Remove config/airlock.php
  5. Remove laravel/airlock from the project’s composer dependencies

Note: be sure to remember to retain any customizations you’ve made to config/airlock.php

Here are the rough commands for all the steps:

# Step 1 - install Sanctum
composer install laravel/sanctum

# Step 2 - Publish the sanctum vendor config
php artisan vendor:publish \
  --provider="Laravel\Sanctum\SanctumServiceProvider"

# Step 3
# Manually find/replace Airlock instances in your code

# Step 4 - if you published config/sanctum.php
rm config/airlock.php

# Step 5
composer remove laravel/airlock

Here’s the example from the documentation for importing the Sanctum middleware, so if you’ve done this already in your project change use Laravel\Airlock\... to reference use Laravel\Sanctum\... instead:

use Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful;

'api' => [
    EnsureFrontendRequestsAreStateful::class,
    'throttle:60,1',
    \Illuminate\Routing\Middleware\SubstituteBindings::class,
],

Learn More

To learn more about using Sanctum, check out the official documenation. The source code is on GitHub at laravel/sanctum.

Filed in: News
Laravel News Partners

Laravel Jobs

Backend Software Engineer (PHP Developer)
Austin TX, Bonita Springs FL
Certified eSupport Corp
Laravel Developer
Glendale, CA (COVID Remote)
Jogg, Inc
Full-Stack Engineer (Mid to Senior)
Remote (EST, CST)
Voxie
Senior Laravel Developer (AI Applications)
Remote from anywhere in the UK or from our London office
GreenShoot Labs
Full Stack Engineer
Remote
Shelterluv

Newsletter

Join 31,000+ others and never miss out on new tips, tutorials, and more.