nyholm/psr7) and PSR-15 middleware patterns. The package’s core design (stateless, header-based auth) fits Laravel’s middleware pipeline seamlessly, though PSR-15 support is still limited to Laravel’s Kernel.php integration.Auth facade compatibility. Developers must build these layers manually.Kernel.php:
'auth.basic' => \JimTools\BasicAuth\Middleware\BasicAuthMiddleware::class,
nyholm/psr7 v1.5+ is required. Conflict risk if other packages enforce v1.4 or lower.Auth::attempt()). No built-in integration with Laravel’s Auth or HasApiTokens traits.throttle middleware).VerifyCsrfToken separately).Hash::make()).auth:api or a maintained package (e.g., spatie/laravel-http-basic-auth).Auth::attempt() (requires custom user provider)?AuthService)?benchmark() helper.401 responses? Example:
$middleware->setUnauthorizedCallback(fn () => response('Unauthorized', 401)->header('WWW-Authenticate', 'Basic'));
Authorization headers?auth.basic (if using v11+)?spatie/laravel-http-basic-auth (actively maintained)?// Current (legacy)
Route::group(['middleware' => 'auth.basic'], function () { ... });
// Target (package)
Route::middleware(['auth.basic'])->get('/protected');
Authorization: Basic ...).401, 403).use JimTools\BasicAuth\Middleware\BasicAuthMiddleware;
$middleware = new BasicAuthMiddleware(app(AuthService::class));
$middleware->handle($request, $next);
nyholm/psr7 (v2.x in Symfony 6).^10.0 in composer.json until v11 testing is complete.nyholm/psr7 must be v1.5+. Conflict risk with:
guzzlehttp/psr7 (v1.x).composer require nyholm/psr7:^1.5 and enforce version.AuthService::validate(string $username, string $password): bool).class AuthService {
public function validate(string $username, string $password): bool {
return Hash::check($password, User::find($username)?->password);
}
}
Kernel.php after binding the service:
$app->bind(AuthService::class, fn () => new AuthService());
How can I help you explore Laravel packages today?