PHPackages                             andrazero121/api-resource-typer - 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. andrazero121/api-resource-typer

ActiveLibrary[API Development](/categories/api)

andrazero121/api-resource-typer
===============================

A Laravel package to automatically generate TypeScript interfaces from API Resource Controllers

v1.0.8(10mo ago)126↓50%MITPHPPHP ^8.2CI failing

Since Jun 29Pushed 10mo agoCompare

[ Source](https://github.com/AndraZero121/api-resource-typer)[ Packagist](https://packagist.org/packages/andrazero121/api-resource-typer)[ RSS](/packages/andrazero121-api-resource-typer/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (5)Versions (9)Used By (0)

API Resource Typer
==================

[](#api-resource-typer)

🚀 Automatically generate TypeScript or JavaScript interfaces from your Laravel API Resource Controllers!

Features
--------

[](#features)

- ✅ Auto-generate TypeScript or JavaScript interfaces from API responses
- ✅ Support for Laravel Resource and ResourceCollection
- ✅ Smart type inference from actual data
- ✅ Artisan command for manual generation with output type selection
- ✅ Middleware for automatic generation
- ✅ Trait for easy controller integration
- ✅ Configurable type mappings
- ✅ Pagination support

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

[](#installation)

```
composer require andrazero121/api-resource-typer
```

Publish the config file:

```
php artisan vendor:publish --provider="AndraZero121\ApiResourceTyper\Providers\ApiResourceTyperServiceProvider" --tag=api-resource-typer-config
php artisan vendor:publish --provider="AndraZero121\ApiResourceTyper\Providers\ApiResourceTyperServiceProvider" --tag=api-resource-typer-extension
```

Usage
-----

[](#usage)

### Method 1: Using Trait

[](#method-1-using-trait)

Add the trait to your API controllers:

```
