PHPackages                             triquang/laravel-model-doc - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. triquang/laravel-model-doc

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

triquang/laravel-model-doc
==========================

Generates PHPDoc annotations (@property, etc.) for Eloquent models, supporting both standard and modular Laravel applications.

1.1.0(8mo ago)012MITPHPPHP ^8.0

Since Jul 28Pushed 8mo agoCompare

[ Source](https://github.com/ntquangkk/laravel-model-doc)[ Packagist](https://packagist.org/packages/triquang/laravel-model-doc)[ RSS](/packages/triquang-laravel-model-doc/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (1)Versions (3)Used By (0)

Laravel Model Doc Generator
===========================

[](#laravel-model-doc-generator)

[![Latest Version on Packagist](https://camo.githubusercontent.com/c8859f989eab8b5fb74f18827399fa3fa6d50b9a606591a489be1289e5fbd55f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7472697175616e672f6c61726176656c2d6d6f64656c2d646f632e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/triquang/laravel-model-doc)[![Total Downloads](https://camo.githubusercontent.com/074a33e3256312f2807b9ee8a3b401193a5906ec5644e686abd41cf5e1783eb1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7472697175616e672f6c61726176656c2d6d6f64656c2d646f632e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/triquang/laravel-model-doc)[![License](https://camo.githubusercontent.com/8dbd4dfb6f0efd75fe9fd162f3faaf70a82736de0831072b1ababa6673094a68/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f7472697175616e672f6c61726176656c2d6d6f64656c2d646f632e7376673f7374796c653d666c61742d737175617265)](https://github.com/ntquangkk/laravel-model-doc?tab=MIT-1-ov-file)

A Laravel Artisan command that generates PHPDoc blocks for your Eloquent models based on your database schema and relationships.

> Example:

```
/**
 * @table quizzes
 * @property  int     $id           bigint     No description
 * @property  string  $description  text       No description
 * @property  string  $level        enum       {easy, medium, difficult}
 * @property  string  $title        varchar    No description
 * @property  Carbon  $created_at   timestamp  No description
 * @property  Carbon  $updated_at   timestamp  No description
 * @property-read Collection|QuizQuestion[] $questions
 */
```

---

🚀 Features
----------

[](#-features)

- Generate `@property` based on SQL column types.
- Detect `@property-read` from relationships.
- Support models in:
    - `app/Models`
    - `Modules/*/app/Models` (modular structure)
- Sort by:
    - PHP type (default)
    - Property name
    - DB type
- Supports multiple DB drivers: MySQL, PostgreSQL, SQLite, SQL Server, Oracle.

---

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

[](#-installation)

This package is intended for development only.
Please install it using the `--dev` flag:

Install via Composer:

```
composer require triquang/laravel-model-doc --dev
```

---

⚙️ Usage
--------

[](#️-usage)

Run the Artisan command:

```
php artisan gen:model-doc [options]
```

### Options

[](#options)

OptionDescription`--model`Only process a specific model (FQCN). Example: `App\\Models\\User`.`--dry-run`Show output to screen without modifying files.`--sort`Sort by: `type` (PHP type), `name`, or `db` (PHP + DB + name).`--ns`Select namespaces to scan. Example: `Modules\\Domain\\Models`.---

🧠 How It Works
--------------

[](#-how-it-works)

- Reads model classes from `app/Models` and `Modules/*/app/Models` or from namespaces
- Uses DB schema to map SQL types → PHP types
- Detects Eloquent relationships (e.g., `hasMany`, `belongsTo`)
- Writes `/** ... */` docblock directly under `
