Download the PHP package inmanturbo/homework without Composer

On this page you can find all versions of the php package inmanturbo/homework. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package homework

inmanturbo/homework

Tests Check PHP code style

A Laravel Passport extension that provides WorkOS UserManagement API compatibility, allowing you to use Laravel Passport as a drop-in replacement for WorkOS authentication services.

Quick Start

Table of Contents

Overview

This package extends Laravel Passport to provide WorkOS-compatible OAuth endpoints, enabling you to self-host your authentication service while maintaining full compatibility with the Laravel WorkOS SDK client applications.

Key Benefits:

Features

Related Packages

Homework Organizations - Database-per-organization multi-tenancy for Laravel applications. Provides automatic organization database switching, storage isolation, and queue context propagation. Perfect companion for building multi-organization SaaS applications with Homework OAuth authentication.

Requirements

Installation

Step 1: Install the Package

Via Composer:

Or for local development, add to your composer.json:

Step 2: Install Laravel Passport

If you haven't already installed Passport:

That's it! The package automatically registers all necessary routes and views.

Usage

Setting Up OAuth Clients

Option 1: Using Artisan Command (Easiest)

Create a first-party WorkOS client using the provided Artisan command:

This will output ready-to-copy environment variables and an auto-install script:

Auto-Install Script:

The one-liner bash command will automatically:

Simply cd into your client Laravel project and paste the command!

Option 2: Using the ClientService

Programmatically create a first-party WorkOS-compatible client:

This will return all the configuration details you need:

Multiple Redirect URIs:

Option 3: Using Passport's Artisan Commands

You can also use Laravel Passport's built-in Artisan commands:

Public Client (No Client Secret)

Public clients are suitable for SPAs and mobile apps that cannot securely store secrets:

When prompted, enter your redirect URI (e.g., http://your-app.test/authenticate).

Confidential Client (With Client Secret)

Confidential clients are suitable for server-side applications that can securely store secrets:

When prompted:

  1. Enter your redirect URI (e.g., http://your-app.test/authenticate)
  2. Choose whether to enable device authorization flow (usually no)

The command will output:

Note: First-party clients (those without a user_id) can automatically bypass the authorization screen when using the optional auto-approval features (see Authorization Flow section below).

Client Application Configuration

Configure your client application's .env to point to your OAuth server:

Then configure the WorkOS SDK to use your OAuth server in app/Providers/AppServiceProvider.php:

Authentication Flow

The package provides these WorkOS-compatible endpoints:

Authorization Flow

By default, the package uses the standard OAuth authorization flow where users see an authorization screen asking them to approve access. You have three options for customizing this behavior:

Option 1: Standard OAuth Flow (Default)

No configuration needed. Users will see the authorization screen on first login.

Option 2: Auto-Approval Using Client Model (Recommended)

Use the provided Client model or trait to automatically approve first-party clients:

Using the Provided Client Model:

Using Your Own Client Model:

If you already have a custom Client model, add the trait:

Then configure Passport to use your model:

Option 3: Auto-Approval Using Middleware

Alternatively, use the provided middleware (kept for backward compatibility):

How Auto-Approval Works:

When using either the Client model approach (Option 2) or middleware approach (Option 3):

Which approach should you use?

Custom Authorization View (Optional)

The package includes a modern, dark-mode-enabled authorization view that you can optionally use. This view is displayed when users need to approve access (when not using auto-approval, or for third-party clients).

Using the Provided Authorization View

Configure Passport to use the package's authorization view:

View Features:

Customizing the View

To use your own authorization view, simply don't configure Passport to use the homework view, and create your own view according to Passport's documentation.

Alternatively, you can override the package's view by creating a file at resources/views/vendor/homework/auth/authorize.blade.php in your application - Laravel will automatically use your version instead of the package's version.

Customizing User Responses

The package provides a flexible way to customize how user data is returned in WorkOS-compatible responses. This is useful for adding support for organizations, custom avatars, or any other user-related data.

Using the workosUser() Method (Recommended)

The simplest way to customize the user response is by adding a workosUser() method to your User model:

The default UserResponse will:

  1. Check if your User model has a workosUser() method
  2. If found, use it to create the WorkOS User object
  3. If not found, create one automatically from common attributes
  4. Automatically include organization_id in the response if present
  5. Handle avatar URL detection from avatar_url, profile_picture_url, or avatar attributes

Creating a Custom User Response

  1. Create a class that implements UserResponseContract:

  2. Bind your custom class in a service provider:

Option 1: Direct Binding

Option 2: Using Homework Facade (Recommended)

The custom user response will now be used for:

Extending the Default Response

You can also extend the default UserResponse class:

Customizing Authentication Responses

For advanced use cases, you can customize the entire authentication response structure (including top-level fields like organization_id, impersonator, etc.):

Creating a Custom Authentication Response

  1. Create a class that implements AuthenticationResponseContract:

  2. Bind your custom class in a service provider:

Option 1: Direct Binding

Option 2: Using Homework Facade (Recommended)

Note: The organization_id must be at the top level of the response for the WorkOS SDK to properly extract it. The default AuthenticationResponse handles this automatically.

Token Claims, Permissions & Metadata

The package supports adding custom claims, permissions, roles, and metadata to authentication tokens, following WorkOS patterns. This allows you to enrich tokens with authorization data without implementing the actual authorization logic in the package.

WorkOS org_id Pattern

Following WorkOS conventions:

Creating a Token Claims Provider

  1. Create a class that implements TokenClaimsProviderContract:

  2. Bind your provider in a service provider:

Response Structure

When a TokenClaimsProvider is bound, the authentication response will include:

Single Organization User:

Multi-Organization User (stateless):

Note: No org_id is included when the user belongs to multiple organizations, keeping the server stateless.

Implementation Notes

Organization Selection Flow

The package supports multi-organization users with an optional organization selection step after login. This is useful when users belong to multiple organizations and need to choose which one to access.

Enabling Organization Selection

  1. Create a class that implements OrganizationProviderContract:

  2. Bind the provider using Homework::useOrganizationProvider():

  3. Add the middleware to your web middleware group:

How it works:

Customizing the Organization Selection View

Similar to Passport's authorization view, you can customize the organization selection screen:

Option 1: Using a Custom View Callback (Headless)

Option 2: Override the Package View

Create a file at resources/views/vendor/homework/auth/select-organization.blade.php - Laravel will automatically use your version instead of the package's version.

Default View Features:

Preserving Intended URLs (Client Application)

In your client application, use Laravel's intended() redirect to preserve the URL users were trying to access:

Response Format

The package returns WorkOS-compatible user responses:

Architecture

Directory Structure

Key Components

Testing

You can test the OAuth flow using curl:

Migration from WorkOS

To migrate from WorkOS to this self-hosted solution:

  1. Install this package on your OAuth server
  2. Create OAuth clients matching your WorkOS application IDs
  3. Update your client application's WORKOS_BASE_URL to point to your OAuth server
  4. Your existing Laravel WorkOS integration will now use your local OAuth server

Benefits

License

MIT

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Support

For issues and questions, please use the GitHub issue tracker.

Credits

This package was created to provide a self-hosted alternative to WorkOS authentication while maintaining full compatibility with the Laravel WorkOS SDK.


All versions of homework with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
laravel/framework Version ^11.0|^12.0
laravel/passport Version ^13.0
laravel/workos Version ^0.5.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package inmanturbo/homework contains the following files

Loading the files please wait ...