laravel/sanctum
Laravel Sanctum provides featherweight authentication for SPAs and simple APIs using token-based and session-based auth. Install it to secure your API routes with minimal configuration.
sanctum:prune-expired command already exist and are maintained by the Laravel core team. The realistic build alternative is 2–4 engineer-weeks plus permanent security ownership. This is a clear "buy" (at zero license cost), and the decision is cheap to reverse because tokens live in one table we control.CheckAbilities / CheckForAnyAbility middleware let us decide scope granularity once — read-only vs. write vs. admin — and enforce it at the route level. This is the mechanism behind "which tier gets which API access," so it should be settled in the API design doc, not discovered during implementation.last_used_at (now opt-in as of 4.3.0) gives customers and support activity visibility; the token-validated event feeds audit logging.personal_access_tokens, and last_used_at write amplification is now configurable. That is a pre-launch decision for high-volume APIs, not a post-launch incident.Adopt when:
Look elsewhere when:
Data caveat: the reported "0 dependents" is a metadata artifact, not an adoption signal. Judge this package on its first-party status, changelog cadence (through 4.3.x, with Laravel 13 and PHP 8.5 support), and its position as the Laravel default. It is well-maintained and low-risk, but it is deliberately minimal — that minimalism is the feature, and also the ceiling.
For executives: Sanctum is the Laravel core team's own authentication package, MIT-licensed, with no vendor contract, no per-seat cost, and no procurement cycle. Adopting it is the lowest-risk way to unblock our SPA, mobile, and partner-API roadmap: it removes an estimated multi-week build, and the maintenance burden sits with the framework maintainers rather than with us. The exit cost is low — tokens live in a table we own — so this is a reversible decision, not a platform commitment.
For engineering: One migration, one trait on the user model, one guard in config, and a scheduled sanctum:prune-expired. Cookie-based auth for the first-party SPA via stateful domains; bearer tokens for everything else. Scope enforcement is route middleware; testing uses actingAs. Two things to settle before we start: (1) our ability/scope naming scheme, since it becomes a public contract with API consumers, and (2) whether last_used_at tracking is on, given its write cost at volume. Known gaps to design around rather than discover: no refresh-token rotation, and no authorization server — if either becomes a requirement, the migration path is Passport or an external IdP, and we should say so in the architecture doc now rather than later.
How can I help you explore Laravel packages today?