PHPackages                             flow96/laravel-bridge - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. flow96/laravel-bridge

ActiveLibrary[API Development](/categories/api)

flow96/laravel-bridge
=====================

A Laravel package that bridges Laravel APIs with TypeScript clients using OpenAPI generation

1.0.3(1mo ago)07MITPHPPHP ^8.3

Since Aug 23Pushed 1mo agoCompare

[ Source](https://github.com/flow96/laravel-bridge)[ Packagist](https://packagist.org/packages/flow96/laravel-bridge)[ RSS](/packages/flow96-laravel-bridge/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (4)Dependencies (24)Versions (4)Used By (0)

Laravel Bridge
==============

[](#laravel-bridge)

[![Latest Version on Packagist](https://camo.githubusercontent.com/07b66b3045d933d5fa518a2977da46e72941033afe102f31b97ddc38dbbd021a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f666c6f7739362f6c61726176656c2d6272696467652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/flow96/laravel-bridge)[![Total Downloads](https://camo.githubusercontent.com/50f9e641cb2ab148609709260c0e619754748ef86fb3aec4983eb5902caacef6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f666c6f7739362f6c61726176656c2d6272696467652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/flow96/laravel-bridge)

Laravel Bridge is a powerful package that seamlessly connects your Laravel API with TypeScript clients by automatically generating type-safe client code from your OpenAPI schemas. Built on top of Laravel Scramble, it provides an effortless way to maintain synchronization between your backend API and frontend client code.

Laravel Bridge uses under the hood:

- [Laravel Scramble](https://scramble.dedoc.co/) for OpenAPI schema generation
- [@hey-api/openapi-ts](https://github.com/hey-api/openapi-ts) for OpenAPI schema generation

For detailed configuration options see [Laravel Scramble](https://scramble.dedoc.co/) and [@hey-api/openapi-ts](https://github.com/hey-api/openapi-ts).

Features
--------

[](#features)

- 🚀 **Automatic TypeScript Client Generation**: Generate fully typed TypeScript clients from your Laravel API
- 📡 **Real-time Watching**: Monitor schema changes and regenerate clients automatically
- 🔧 **Highly Configurable**: Customize output directories, client types, and generation options
- 🎯 **Laravel Scramble Integration**: Leverages the power of Laravel Scramble for OpenAPI schema generation
- 💼 **Multiple Client Types**: Support for fetch, axios, xhr, and node HTTP clients
- 🛡️ **Type Safety**: Full TypeScript type definitions for your API endpoints
- ⚡ **Zero Configuration**: Works out of the box with sensible defaults

Installation
------------

[](#installation)

### Prerequisites

[](#prerequisites)

Before using Laravel Bridge, ensure you have:

1. **Node.js** installed
2. **Composer** installed
3. **Laravel Api Routes** installed (`php artisan install:api`)

### Install Laravel API

[](#install-laravel-api)

```
php artisan install:api
```

### Install the Bridge package

[](#install-the-bridge-package)

You can install the package via Composer:

```
composer require flow96/laravel-bridge
```

### Publishing the configuration

[](#publishing-the-configuration)

Laravel Bridge uses [Scramble](https://scramble.dedoc.co/) under the hood to generate the OpenAPI schema. By publishing the configuration you can modify the Laravel Bridge configuration in `config/bridge.php`, and the Scramble configuration in `config/scramble.php`.

1. Publish the configuration:

```
php artisan vendor:publish --tag=bridge-config
```

Usage
-----

[](#usage)

### Basic Commands

[](#basic-commands)

Scramble (the openapi schema generator) works by default only if your app is running in the `local` environment.

#### Run your application

[](#run-your-application)

Your app must be running with the `local` environment in order for scramble to be able to generate the OpenAPI schema.

```
php artisan serve
```

#### Generate TypeScript Client

[](#generate-typescript-client)

Generate a TypeScript client from your OpenAPI schema:

```
php artisan bridge:generate
```

Generate the client into a different directory for a single run:

```
php artisan bridge:generate --output=../frontend/src/api/client
```

To make the output directory persistent, set it in your `.env` file:

```
BRIDGE_CLIENT_OUTPUT=../frontend/src/api/client
```

You can also set an absolute or computed path in `config/bridge.php`:

```
'output' => base_path('../frontend/src/api/client'),
```

### Using the Generated Client

[](#using-the-generated-client)

After running the generate command, you'll find TypeScript files in your configured output directory. Here's how to use them:

#### With Axios client (default)

[](#with-axios-client-default)

```
import { UserService } from './client/sdk.gen';

// Create a new user
const result = await UserService.create({
    body: {
        name: "John Doe",
        email: "asd@asd.com",
        password: "superSecret"
    }
})

// Get all users
const users = await UserService.getAll();
console.log(users.data.users);
```

Best Practices
--------------

[](#best-practices)

### 1. API Documentation

[](#1-api-documentation)

For the best results, ensure your Laravel controllers are well-documented:

```
public function index(Request $request): JsonResponse
{
    $users = User::all();

    // Type hint is necessary for Eloquent models
    /** @var App\Models\User[] */
    return response(users);
}

public function index(Request $request): JsonResponse
{
    $users = User::all();
    // Resources work out of the box
    return response(UserResource::collection($users));
}

// Parameters of the form request are automatically transformed into typescript types
public function store(CreateUserRequest $request): JsonResponse
{
    $user = User::create($request->validated());
    return response(UserResource::make($user), 201);
}

public function findByName(Request $request): JsonResponse
{
    // Query parameters are automatically transformed into typescript types
    $name = $request->query('name');
    $user = User::where('name', $name)->first();
    return response(UserResource::make($user));
}
```

### 2. Resource Classes

[](#2-resource-classes)

Use Eloquent API Resources for consistent response formatting:

```
class UserResource extends JsonResource
{
    public function toArray($request): array
    {
        return [
            'id' => $this->id,
            'name' => $this->name,
            'email' => $this->email,
            'created_at' => $this->created_at,
            'updated_at' => $this->updated_at,
        ];
    }
}
```

Credits
-------

[](#credits)

- [Laravel Scramble](https://scramble.dedoc.co/) for OpenAPI generation
- [OpenAPI TypeScript](https://github.com/ferdikoomen/openapi-typescript-codegen) for client generation

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

###  Health Score

42

—

FairBetter than 88% of packages

Maintenance92

Actively maintained with recent releases

Popularity5

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~160 days

Total

3

Last Release

41d ago

Major Versions

0.0.1 → 1.0.02026-07-08

PHP version history (2 changes)0.0.1PHP ^8.1

1.0.0PHP ^8.3

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/36381574?v=4)[Florian Lutze](/maintainers/flow96)[@flow96](https://github.com/flow96)

---

Top Contributors

[![flow96](https://avatars.githubusercontent.com/u/36381574?v=4)](https://github.com/flow96 "flow96 (2 commits)")

---

Tags

apiclientlaravelopenapitypescriptBridgescramble

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/flow96-laravel-bridge/health.svg)

```
[![Health](https://phpackages.com/badges/flow96-laravel-bridge/health.svg)](https://phpackages.com/packages/flow96-laravel-bridge)
```

###  Alternatives

[laravel/mcp

Rapidly build MCP servers for your Laravel applications.

79227.1M231](/packages/laravel-mcp)[spatie/laravel-export

Create a static site bundle from a Laravel app

679153.2k7](/packages/spatie-laravel-export)[spatie/laravel-health

Monitor the health of a Laravel application

88212.7M189](/packages/spatie-laravel-health)[simplestats-io/laravel-client

Server-side analytics for Laravel that follows the full funnel from visit to registration to payment, attributed to the channel that drove it. Revenue, MRR, churn and ad-spend profit (ROAS/CAC) per channel. GDPR compliant, ad-blocker proof.

5226.7k](/packages/simplestats-io-laravel-client)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

265.2k](/packages/aedart-athenaeum)[api-platform/laravel

API Platform support for Laravel

58190.1k21](/packages/api-platform-laravel)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
