Laravel Sanctum API token authentication
PHP Dasun Kalupahana 36 views
<?php
// User model: add the HasApiTokens trait
use Laravel\Sanctum\HasApiTokens;
// Create a token
$token = $user->createToken('mobile')->plainTextToken;
// routes/api.php
Route::middleware('auth:sanctum')->get('/user', fn (Request $request) => $request->user());
Issues API tokens for mobile apps and SPAs. In Laravel 11/12, run php artisan install:api first to set up the API scaffolding.
Learn more on the blog
MySQL
PostgreSQL vs MySQL Performance: Real Benchmarks Compared
Last updated: 7 November 2026. See the update log at the end."Which...
8 min read
Laravel
Secure a Laravel App Before Production: Tested Checklist
Last updated: 8 November 2026. See the update log at the end.Laravel...
12 min read
PHP
How to Detect and Fix PHP Memory Leaks
Last updated: 5 November 2026. See the update log at the end.In...
9 min read