PHPackages                             calvient/puddleglum - 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. calvient/puddleglum

ActiveLibrary[API Development](/categories/api)

calvient/puddleglum
===================

Transform Laravel models, routes, and controllers into a Typescript API client

5.0.0(3d ago)314.4k↑256.7%MITPHPPHP ^8.3CI passing

Since Nov 14Pushed 2d ago1 watchersCompare

[ Source](https://github.com/calvient/puddleglum)[ Packagist](https://packagist.org/packages/calvient/puddleglum)[ Docs](https://github.com/calvient/puddleglum)[ RSS](/packages/calvient-puddleglum/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (10)Dependencies (15)Versions (34)Used By (0)

Puddleglum
==========

[](#puddleglum)

[![Latest Version on Packagist](https://camo.githubusercontent.com/d92bb0fd76dedc745b317c75c2442392dd806babd452802d830c9d8dbdd43fc0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f63616c7669656e742f707564646c65676c756d2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/calvient/puddleglum)[![GitHub Tests Action Status](https://camo.githubusercontent.com/35d046e8d8478d75c0b0cd14fcbccb2e77c07a7318fe7608dd1827fe738dfb13/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f63616c7669656e742f707564646c652d676c756d2f72756e2d74657374733f6c6162656c3d7465737473)](https://github.com/calvient/puddleglum/actions?query=workflow%3Arun-tests+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/2de760228c4988654a79573d0e72ec3031f8006817a5734b9a6b50f7a83b2b32/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f63616c7669656e742f707564646c65676c756d2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/calvient/puddleglum)

Puddleglum allows you to automatically generate TypeScript interfaces from your Laravel models and requests as well as a typesafe Axios implementation for your API routes.

This package is based on lepikhinb/laravel-typescript. Special thanks for such an awesome package!

Introduction
------------

[](#introduction)

If you, like Calvient, have a Laravel backend with a TS front-end (be it React, Vue, or something else), you might have noticed that you have to manually keep your TypeScript interfaces in sync with your Laravel models and requests. You might also have noticed that you have to manually keep your Axios implementation in sync with your Laravel routes.

Puddleglum is a Laravel package that solves these problems by automatically generating Typescript interfaces and a simple API implementation based on Axios.

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

[](#installation)

**Laravel 8 and PHP 8 are required.**You can install the package via composer:

```
composer require --dev calvient/puddleglum
```

You can publish the config file with:

```
php artisan vendor:publish --provider="Calvient\Puddleglum\PuddleglumServiceProvider" --tag="puddleglum-config"
```

This is the contents of the published config file:

```
return [
   'output' => resource_path('ts/puddleglum.ts'),
];
```

Usage
-----

[](#usage)

Generate TypeScript interfaces.

```
php artisan puddleglum:generate
```

### Defining your requests

[](#defining-your-requests)

In Laravel, you might define your requests from the command line like this:

```
php artisan make:request StoreUser
```

If you do this (i.e., your requests extend FormRequest), Puddleglum will automatically generate TypeScript interfaces for your requests. The program reads the rules from your FormRequest and generates TypeScript interfaces for your requests.

For example:

```
class UserLogin extends FormRequest
{
	public function authorize()
	{
		return true;
	}

	public function rules()
	{
		return [
			'email' => 'required|email',
			'password' => [
				'required',
				Password::min(8)->mixedCase()->letters()->numbers()->symbols()->uncompromised(),
			],
		];
	}
}
```

Becomes:

```
export interface UserLogin {
	email: string;
	password: string;
}
```

If you don't want to define a FormRequest (e.g., you want to use a request validator directly in your controller), you can use the GlumRequest attribute before your controller.

Example;

```
#[GlumRequest(['name' => 'string', 'email' => 'string', 'password' => 'string'])]
public function register(Request $request) {
    $request->validate([
        'name' => 'required|string|max:255',
        'email' => 'required|string|email|max:255|unique:users',
        'password' => Password::min(8)
            ->letters()
            ->mixedCase()
            ->numbers()
            ->symbols()
            ->uncompromised(),
    ]);
}
```

### Defining Responses

[](#defining-responses)

Defining a response is a bit trickier, because PHP lacks support for generics. However, Puddleglum can still generate TypeScript interfaces for your responses.

We accomplish this by using a PHP attribute.

Example:

```
#[GlumResponse(['user' => 'User', 'message' => 'string'])]
public function show(User $user): User
{
    return response()->json([
        'user' => $user,
        'message' => 'Hello, world!',
    ]);
}
```

Using the Puddleglum Output in your TypeScript code
---------------------------------------------------

[](#using-the-puddleglum-output-in-your-typescript-code)

Import the Puddleglum client into your TypeScript code:

```
import {Puddleglum} from '../../puddleglum';
```

Then, you can use the Puddleglum client to make API calls:

```
const login = async (email: string, password: string) => {
    const reply = await Puddleglum.Auth.LoginController.login({email, password});
    setUser(reply.data.user);
};
```

The API client mirrors the PHP namespace. So, in the example above, the login controller is at `\App\Http\Controllers\Auth`and the method is named `login`.

You can also import various models and requests.

```
import {User} from '../../puddleglum';

const [user, setUser] = React.useState();
```

License
-------

[](#license)

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

###  Health Score

58

↑

FairBetter than 98% of packages

Maintenance99

Actively maintained with recent releases

Popularity28

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity73

Established project with proven stability

 Bus Factor1

Top contributor holds 54.1% 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 ~47 days

Recently: every ~173 days

Total

29

Last Release

3d ago

Major Versions

1.3.4 → 2.0.02024-04-17

2.0.x-dev → 3.0.02024-08-07

3.0.4 → 4.0.02026-02-16

4.0.0 → 5.0.02026-07-01

PHP version history (3 changes)1.0.0PHP ^8.1

2.0.0PHP ^8.2

2.1.0PHP ^8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/d453241866422e72be0bceef88357bbca6f5e1fbd55e803bfc197f3abeb9d9c2?d=identicon)[JonathanCalvient](/maintainers/JonathanCalvient)

![](https://avatars.githubusercontent.com/u/23508481?v=4)[Jonathan Minson](/maintainers/jonathanminson)[@jonathanminson](https://github.com/jonathanminson)

---

Top Contributors

[![jonathanminson](https://avatars.githubusercontent.com/u/23508481?v=4)](https://github.com/jonathanminson "jonathanminson (53 commits)")[![lepikhinb](https://avatars.githubusercontent.com/u/17538801?v=4)](https://github.com/lepikhinb "lepikhinb (34 commits)")[![media253](https://avatars.githubusercontent.com/u/28750663?v=4)](https://github.com/media253 "media253 (3 commits)")[![devoNOTbevo](https://avatars.githubusercontent.com/u/15235244?v=4)](https://github.com/devoNOTbevo "devoNOTbevo (2 commits)")[![trinajkenyon](https://avatars.githubusercontent.com/u/97560931?v=4)](https://github.com/trinajkenyon "trinajkenyon (1 commits)")[![chancezeus](https://avatars.githubusercontent.com/u/2089196?v=4)](https://github.com/chancezeus "chancezeus (1 commits)")[![tyler-cushing](https://avatars.githubusercontent.com/u/71454758?v=4)](https://github.com/tyler-cushing "tyler-cushing (1 commits)")[![ekvedaras](https://avatars.githubusercontent.com/u/3586184?v=4)](https://github.com/ekvedaras "ekvedaras (1 commits)")[![Litiano](https://avatars.githubusercontent.com/u/8152537?v=4)](https://github.com/Litiano "Litiano (1 commits)")[![robmeijerink](https://avatars.githubusercontent.com/u/14540290?v=4)](https://github.com/robmeijerink "robmeijerink (1 commits)")

---

Tags

laraveltypescriptpuddleglum

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

### Embed Badge

![Health badge](/badges/calvient-puddleglum/health.svg)

```
[![Health](https://phpackages.com/badges/calvient-puddleglum/health.svg)](https://phpackages.com/packages/calvient-puddleglum)
```

###  Alternatives

[dedoc/scramble

Automatic generation of API documentation for Laravel applications.

2.1k11.2M100](/packages/dedoc-scramble)[spatie/laravel-pdf

Create PDFs in Laravel apps

1.0k4.8M47](/packages/spatie-laravel-pdf)[defstudio/telegraph

A laravel facade to interact with Telegram Bots

816333.8k3](/packages/defstudio-telegraph)[rawilk/profile-filament-plugin

Profile &amp; MFA starter kit for filament.

3914.6k](/packages/rawilk-profile-filament-plugin)[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.

5021.9k](/packages/simplestats-io-laravel-client)[lettermint/lettermint-laravel

Official Lettermint driver for Laravel

1190.2k1](/packages/lettermint-lettermint-laravel)

PHPackages © 2026

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