corbado/client-php
Corbado client for PHP adds passwordless authentication to Laravel/PHP apps, supporting passkeys and email-based login flows through Corbado’s APIs. Integrate secure, phishing-resistant sign-in without managing passwords.
Treat this package as a vendor SDK for an existing Corbado/passkey integration, not a general-purpose auth package. It is archived, so pin the version and isolate it behind your own interface before building on it.
composer require corbado/client-php
config/services.php, not directly in code:
'corbado' => [
'project_id' => env('CORBADO_PROJECT_ID'),
'api_secret' => env('CORBADO_API_SECRET'),
],
src/Client.php and the exception classes. The important surface is usually: construct a client with project ID/API secret, then call resource accessors such as sessions(), users(), identifiers(), and passkeys().$this->app->singleton(\Corbado\Client::class, function () {
return new \Corbado\Client(
projectId: config('services.corbado.project_id'),
apiSecret: config('services.corbado.api_secret'),
);
});
Check the README for the exact constructor signature in your pinned release.$session = app(\Corbado\Client::class)
->sessions()
->verify($request->bearerToken());
$user = User::firstOrCreate(
['corbado_user_id' => $session->userID],
['name' => $session->userName ?? 'Passkey user'],
);
Auth::login($user);
Do not expect this package to render passkey UI. Corbado’s frontend component/API handles registration and login; this SDK is the backend verification and management layer.
Middleware-based session verification Centralize token verification in middleware rather than repeating it in controllers. Attach the verified session to the request:
$request->attributes->set('corbado_session', $session);
Then resolve your local user from corbado_user_id. This keeps your controllers free of SDK calls and makes it easy to swap the SDK later.
Frontend-to-backend exchange Typical flow:
sessions()->verify(...).Do not store the Corbado token as your long-lived application session. Exchange it once.
Local user mapping
Add a nullable, unique corbado_user_id to your users table. Resolve users by that ID, not by email, because identifiers can change. For first login, use a transaction or firstOrCreate to avoid duplicate users under concurrent requests.
Backend administration Use the SDK for account management screens or Artisan commands:
Wrap these calls in small service methods such as CorbadoAccountService::deletePasskey($userId, $passkeyId) so controllers do not depend directly on SDK response shapes.
Laravel integration tips
AppServiceProvider or a dedicated CorbadoServiceProvider.app() calls inside domain code.401 when session verification fails and 503 when Corbado is unreachable. Do not silently authenticate on network failure.Testing
Mock your own CorbadoGateway interface rather than mocking the SDK’s concrete client. Add one integration test against a Corbado test project for the real token-verification path.
composer outdated, and plan to fork or replace it. If you are starting fresh, evaluate Corbado’s current SDK guidance or another passkey provider first.CORBADO_API_SECRET is backend-only. Never expose it through Inertia props, VITE_ variables, JavaScript config, or logs. Rotate it in the Corbado dashboard if leaked.config('services.corbado.*') in providers. Calling env() after php artisan config:cache returns null.401) from Corbado outage (503), rate limiting (429), and misconfiguration (401/403 from Corbado with a valid-looking token).CorbadoGateway around the SDK. Inject a logging PSR-18 client in non-production to see raw HTTP calls. If you need webhook handling or token introspection that the SDK does not provide, implement it separately and keep it outside the archived dependency.How can I help you explore Laravel packages today?