PHPackages                             andrazero121/docs-horizon - 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/docs-horizon

ActiveLibrary[API Development](/categories/api)

andrazero121/docs-horizon
=========================

Generate Frontend type definitions from Laravel Backend structure.

v1.4.0(8mo ago)07MITPHPPHP ^8.2

Since Aug 19Pushed 8mo agoCompare

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

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

🌅 Docs Horizon
==============

[](#-docs-horizon)

[![Latest Version on Packagist](https://camo.githubusercontent.com/6d5ff66d2c12b32c127911a4124e04cd27e52f62dafa27a700e47dcce0fec755/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f616e6472617a65726f3132312f646f63732d686f72697a6f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/andrazero121/docs-horizon)[![Total Downloads](https://camo.githubusercontent.com/6bb8881bc17749de39bbe6ba423594669622f40deacf1dbe3eff8d26aff03cfd/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f616e6472617a65726f3132312f646f63732d686f72697a6f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/andrazero121/docs-horizon)[![License](https://camo.githubusercontent.com/31b6af556986e8ab84cf88a1f594908464b4bf1019b5126676642c07cfdcc965/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f616e6472617a65726f3132312f646f63732d686f72697a6f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/andrazero121/docs-horizon)

Automatically generate Frontend type definitions from your Laravel Backend structure. Bridge the gap between your Laravel models, validations, and migrations with TypeScript interfaces for seamless full-stack development.

✨ Features
----------

[](#-features)

- 🔍 **Multi-Source Analysis** - Extracts data from Models, Controller validations, and Migrations
- 🎯 **TypeScript Generation** - Creates clean TypeScript interfaces for your frontend
- 📄 **JSON Schema Export** - Generates JSON schema for API documentation
- 🚀 **CLI Only** - Secure generation through Artisan commands only
- 🔄 **Smart Type Mapping** - Intelligently converts PHP/Laravel types to TypeScript
- 📁 **Organized Output** - Creates structured files in `resources/js/docs-api/`

📦 Installation
--------------

[](#-installation)

```
composer require andrazero121/docs-horizon
```

The package will automatically register its service provider.

🚀 Usage
-------

[](#-usage)

### Generate Type Definitions

[](#generate-type-definitions)

Run the Artisan command to analyze your Laravel application and generate type definitions:

```
php artisan docs:horizon
```

This command will:

1. 📊 Analyze all Models in `app/Models/`
2. 🔍 Extract validation rules from Controllers
3. 📋 Read column types from Migration files
4. 🔄 Merge and convert data to frontend-friendly format
5. 📝 Generate TypeScript and JSON files

### Output Structure

[](#output-structure)

After running the command, you'll find generated files in:

```
resources/js/docs-api/
├── types.ts        # TypeScript interface definitions
├── schema.json     # JSON schema for API documentation
└── index.ts        # Barrel export file

```

📋 Example Output
----------------

[](#-example-output)

### Generated TypeScript Interfaces (`types.ts`)

[](#generated-typescript-interfaces-typests)

```
// Auto-generated by Docs Horizon
// Do not edit this file manually

export interface Users {
  id: number;
  name: string;
  email: string;
  email_verified_at: string | null;
  password: string;
  remember_token: string | null;
  created_at: string;
  updated_at: string;
}

export interface Posts {
  id: number;
  title: string;
  content: string;
  excerpt: string | null;
  user_id: number;
  published: boolean;
  published_at: string | null;
  created_at: string;
  updated_at: string;
}

export interface Categories {
  id: number;
  name: string;
  slug: string;
  description: string | null;
  created_at: string;
  updated_at: string;
}
```

### Generated JSON Schema (`schema.json`)

[](#generated-json-schema-schemajson)

```
{
  "users": {
    "id": "number",
    "name": "string",
    "email": "string",
    "email_verified_at": "string",
    "password": "string",
    "remember_token": "string",
    "created_at": "string",
    "updated_at": "string"
  },
  "posts": {
    "id": "number",
    "title": "string",
    "content": "string",
    "excerpt": "string",
    "user_id": "number",
    "published": "boolean",
    "published_at": "string",
    "created_at": "string",
    "updated_at": "string"
  }
}
```

💡 Frontend Usage
----------------

[](#-frontend-usage)

### In TypeScript/JavaScript

[](#in-typescriptjavascript)

```
import { Users, Posts, Categories } from '@/docs-api';

// Type-safe object creation
const user: Users = {
  id: 1,
  name: 'John Doe',
  email: 'john@example.com',
  // TypeScript will ensure all required fields are present
};

// API response typing
async function fetchUser(id: number): Promise {
  const response = await fetch(`/api/users/${id}`);
  return response.json(); // Typed as Users interface
}

// Form validation
function validateUserForm(data: Partial): boolean {
  // Your validation logic with type safety
  return data.name !== undefined && data.email !== undefined;
}
```

### In Vue.js

[](#in-vuejs)

```

import { ref } from 'vue';
import type { Users, Posts } from '@/docs-api';

const user = ref({
  id: 0,
  name: '',
  email: '',
  // All properties are typed and autocompleted
});

const posts = ref([]);

```

### In React

[](#in-react)

```
import React, { useState } from 'react';
import type { Users, Posts } from '@/docs-api';

export default function UserProfile() {
  const [user, setUser] = useState(null);
  const [posts, setPosts] = useState([]);

  // Component logic with full type safety
}
```

🔧 How It Works
--------------

[](#-how-it-works)

Docs Horizon uses a sophisticated multi-layer analysis approach:

### 1. **Nova** - Type Extraction Engine

[](#1-nova---type-extraction-engine)

- Scans Controller validation rules
- Parses Migration files for column definitions
- Maps Laravel validation types to TypeScript types

### 2. **Rafflesia** - Model Analysis

[](#2-rafflesia---model-analysis)

- Analyzes Eloquent Models
- Extracts fillable fields
- Determines table relationships

### 3. **Lane** - Data Conversion

[](#3-lane---data-conversion)

- Merges data from all sources
- Resolves conflicts with smart prioritization
- Normalizes field names and types

### 4. **Helvetica** - File Generation

[](#4-helvetica---file-generation)

- Creates clean TypeScript interfaces
- Generates comprehensive JSON schemas
- Maintains consistent formatting

🎯 Type Mapping
--------------

[](#-type-mapping)

Laravel/PHP TypeTypeScript TypeNotes`string``string`Text fields`integer`, `bigInteger``number`Numeric fields`boolean``boolean`True/false values`json``object`JSON objects`array``any[]`Array types`text`, `longText``string`Text content`timestamp`, `date``string`ISO date strings`decimal`, `float``number`Decimal numbers🔄 Data Source Priority
----------------------

[](#-data-source-priority)

When multiple sources define the same field, Docs Horizon uses this priority order:

1. **Migration files** (highest priority) - Most accurate column definitions
2. **Model fillable fields** - Business logic constraints
3. **Controller validation rules** (lowest priority) - Request validation

📚 Advanced Usage
----------------

[](#-advanced-usage)

### Custom Type Mapping

[](#custom-type-mapping)

You can extend the type mapping by modifying the generated files after creation, but remember they will be overwritten on the next generation.

### Integration with Build Tools

[](#integration-with-build-tools)

Add the generation command to your build process:

```
{
  "scripts": {
    "build": "php artisan docs:horizon && npm run build",
    "dev": "php artisan docs:horizon && npm run dev"
  }
}
```

### Watch Mode (Coming Soon)

[](#watch-mode-coming-soon)

```
php artisan docs:horizon --watch
```

🐛 Troubleshooting
-----------------

[](#-troubleshooting)

### Common Issues

[](#common-issues)

**No types generated?**

- Ensure you have Models in `app/Models/`
- Check that your Models extend `Illuminate\Database\Eloquent\Model`
- Verify Migration files exist in `database/migrations/`

**Missing fields in output?**

- Check that fields are defined in `$fillable` array in your Models
- Ensure Migration files use standard Laravel column types
- Verify Controller validation rules use supported validation types

**TypeScript errors?**

- Make sure your TypeScript configuration includes the `resources/js` directory
- Update your path aliases to include `@/docs-api`

### Debug Mode

[](#debug-mode)

Run with verbose output to see what's being processed:

```
php artisan docs:horizon -v
```

🤝 Contributing
--------------

[](#-contributing)

We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.

### Development Setup

[](#development-setup)

1. Clone the repository
2. Install dependencies: `composer install`
3. Run tests: `composer test`
4. Check code style: `composer cs-fix`

📄 License
---------

[](#-license)

This package is licensed under the MIT License. See the [LICENSE](LICENSE.md) file for details.

🆘 Support
---------

[](#-support)

- 📖 [Documentation](https://github.com/andrazero121/docs-horizon/wiki)
- 🐛 [Issue Tracker](https://github.com/andrazero121/docs-horizon/issues)
- 💬 [Discussions](https://github.com/andrazero121/docs-horizon/discussions)

🚀 Roadmap
---------

[](#-roadmap)

- **v1.1** - Relationship mapping support
- **v1.2** - Watch mode for auto-regeneration
- **v1.3** - Custom configuration file
- **v1.4** - Support for Enum types
- **v1.5** - GraphQL schema generation
- **v2.0** - Plugin system for custom generators

🙏 Acknowledgments
-----------------

[](#-acknowledgments)

- Inspired by the Laravel and TypeScript communities
- Built with love for full-stack developers
- Special thanks to all contributors and users

---

**Made with ❤️ by [andrazero121](https://github.com/andrazero121)**

⭐ **Star this repo if it helped you!** ⭐

###  Health Score

33

—

LowBetter than 74% of packages

Maintenance62

Regular maintenance activity

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity52

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 ~0 days

Total

5

Last Release

263d ago

### Community

Maintainers

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

---

Top Contributors

[![AndraZero121](https://avatars.githubusercontent.com/u/165757945?v=4)](https://github.com/AndraZero121 "AndraZero121 (10 commits)")

---

Tags

apiconverterdocs-generator

### Embed Badge

![Health badge](/badges/andrazero121-docs-horizon/health.svg)

```
[![Health](https://phpackages.com/badges/andrazero121-docs-horizon/health.svg)](https://phpackages.com/packages/andrazero121-docs-horizon)
```

###  Alternatives

[spatie/laravel-query-builder

Easily build Eloquent queries from API requests

4.4k26.9M219](/packages/spatie-laravel-query-builder)[andreaselia/laravel-api-to-postman

Generate a Postman collection automatically from your Laravel API

1.0k586.2k3](/packages/andreaselia-laravel-api-to-postman)[fumeapp/modeltyper

Generate TypeScript interfaces from Laravel Models

196277.9k](/packages/fumeapp-modeltyper)[saloonphp/laravel-plugin

The official Laravel plugin for Saloon

765.7M124](/packages/saloonphp-laravel-plugin)[essa/api-tool-kit

set of tools to build an api with laravel

52680.5k](/packages/essa-api-tool-kit)[mll-lab/laravel-graphiql

Easily integrate GraphiQL into your Laravel project

683.2M9](/packages/mll-lab-laravel-graphiql)

PHPackages © 2026

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