Laravel logo

Integrate WorkOS using the Laravel SDK

Easily add enterprise features like Single Sign-On (SSO/SAML), Directory Sync (SCIM), Audit Trail (SIEM), and Access Control (IAM) to your Laravel app.

Installation

You can install the Laravel SDK with Composer using the following command:

Terminal

file_copy
composer require workos/workos-php-laravel

Usage

Below is an example integration that adds SSO using the Laravel SDK. You can find other examples and more information in our Laravel SDK Docs.

Laravel

file_copy
use IlluminateHttpRequest;
use IlluminateSupportFacadesRoute;

const DOMAIN = "example.com";
const REDIRECT_URI = "REDIRECT_URI";

Route::get("login", function() {
    return view("login", [
        "authUrl" => (new WorkOSSSO())->getAuthorizationUrl(
            DOMAIN, 
            REDIRECT_URI, 
            ["result" => "data"], 
            null
        )
    ]);
});

Route::get("auth/callback", function(Request $request) {
    $code = $request->input("code");
    $profile = (new WorkOSSSO())->getProfile($code);
    return response()->json($profile->toArray());
});

Start Integrating Today

Create an account to begin adding enterprise-ready features to your application today.