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

0.0.1(8mo ago)02MITPHPPHP ^8.1

Since Aug 23Pushed 8mo 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 1mo ago

READMEChangelog (1)Dependencies (8)Versions (2)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 scramble configuration in the `config/scramble.php` file.

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
```

### 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

27

—

LowBetter than 49% of packages

Maintenance63

Regular maintenance activity

Popularity2

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity34

Early-stage or recently created project

 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

Unknown

Total

1

Last Release

258d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2f2d641f30c9e8e55b45b2000d727802b0b06db7b5c62424cd4cd754264da324?d=identicon)[flow96](/maintainers/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

[resend/resend-laravel

Resend for Laravel

1191.4M6](/packages/resend-resend-laravel)

PHPackages © 2026

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