Laravel Airlock Renamed to Sanctum
Published on by Paul Redmond
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:
- Add the
laravel/sanctum
composer dependency - Either publish the sanctum vendor config or move the existing
config/airlock.php
config - Find/replace
Airlock
forSanctum
andairlock
forsanctum
- If you’re using the middleware for a SPA, change
Airlock
toSanctum
- Update any environment configuration for
AIRLOCK_STATEFUL_DOMAINS
toSANCTUM_STATEFUL_DOMAINS
- Remove
config/airlock.php
- 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 Sanctumcomposer install laravel/sanctum # Step 2 - Publish the sanctum vendor configphp artisan vendor:publish \ --provider="Laravel\Sanctum\SanctumServiceProvider" # Step 3# Manually find/replace Airlock instances in your code # Step 4 - if you published config/sanctum.phprm config/airlock.php # Step 5composer 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.