web-token/jwt-easy
Simple JWT helper for PHP apps: quickly encode, decode, and validate JSON Web Tokens with minimal setup. Designed for straightforward auth flows, with easy-to-use APIs for signing, verifying, and reading claims.
firebase/php-jwt or lcobucci/jwt.composer.json).Illuminate\Support\Facades\Auth or typhon/jwt-auth.JwtGuard).web-token/jwt-framework (core library) – verify compatibility with Laravel’s PSR-15/PSR-11 containers.HS256/RS256 defaults).lcobucci/jwt for large-scale use.lcobucci/jwt (more stars, active maintenance) or firebase/php-jwt.sanctum/passport or coexist? Plan for guard/middleware conflicts.sanctum sessions, passport OAuth2) to identify JWT-specific needs.lcobucci/jwt for performance/critical paths./api/v1/protected) with jwt-easy.jwt-easy + Laravel’s HandleIncomingRequest) for request/response flow.Illuminate\Auth\Middleware\Authenticate or create a custom JwtMiddleware.
use WebToken\JWT\JWT;
public function handle($request, Closure $next) {
$token = $request->bearerToken();
if (!$token || !JWT::validate($token)) {
return response()->json(['error' => 'Unauthorized'], 401);
}
return $next($request);
}
JwtGuard in AuthServiceProvider:
$this->app['auth']->extend('jwt', function ($app) {
return new JwtGuard(new JwtUserProvider());
});
AppServiceProvider to bind JWT facade if needed.JWT::encode()/JWT::decode() for auth endpoints.JwtMiddleware.user_id, scopes) via JWT::setClaim().monolog integration).| Failure | Impact | Mitigation |
|---|---|---|
| Token leakage | Data breach | Enforce short TTLs, use RS256, audit logs. |
| Algorithm downgrade | Weak security | Enforce HS256/RS256 via middleware. |
| Clock skew | Token validation failures | Use nbf/iat claims with buffer. |
| Package abandonment | No updates | Fork or migrate to lcobucci/jwt. |
| Redis failure (revocation) | False positives | Fallback to allow-list in DB. |
jwt-easy API.How can I help you explore Laravel packages today?