PHPackages                             romanzipp/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. [Database &amp; ORM](/categories/database)
4. /
5. romanzipp/laravel-model-doc

ActiveLibrary[Database &amp; ORM](/categories/database)

romanzipp/laravel-model-doc
===========================

Laravel Model PHPDoc Generator

3.4.0(6mo ago)3166.9k↓15.3%9[1 issues](https://github.com/romanzipp/Laravel-Model-Doc/issues)[3 PRs](https://github.com/romanzipp/Laravel-Model-Doc/pulls)MITPHPPHP ^8.2CI passing

Since Jan 15Pushed 3mo ago2 watchersCompare

[ Source](https://github.com/romanzipp/Laravel-Model-Doc)[ Packagist](https://packagist.org/packages/romanzipp/laravel-model-doc)[ GitHub Sponsors](https://github.com/romanzipp)[ RSS](/packages/romanzipp-laravel-model-doc/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (10)Versions (46)Used By (0)

Laravel Model PHPDoc Generator
==============================

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

[![Latest Stable Version](https://camo.githubusercontent.com/d2241e64ac504e67eda1f5933dd4928596b9a4fe35d7ba024407ab88b632dccf/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f726f6d616e7a6970702f4c61726176656c2d4d6f64656c2d446f632e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/romanzipp/laravel-model-doc)[![Total Downloads](https://camo.githubusercontent.com/5e33e9bb68a488fa51e6a4014617a07d3195e68614db69a55d472b4d84f42cd8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f726f6d616e7a6970702f4c61726176656c2d4d6f64656c2d446f632e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/romanzipp/laravel-model-doc)[![License](https://camo.githubusercontent.com/bfb30eb5c421a9bf28883e67738aed9b942826b90864520ecefc0dc912fc6f94/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f726f6d616e7a6970702f4c61726176656c2d4d6f64656c2d446f632e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/romanzipp/laravel-model-doc)[![GitHub Build Status](https://camo.githubusercontent.com/f686c232653ae30295701039aa270788b1356e49d5711fdc5bf5bf29e56b4876/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f726f6d616e7a6970702f4c61726176656c2d4d6f64656c2d446f632f74657374732e796d6c3f6272616e63683d6d6173746572266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/romanzipp/Laravel-Model-Doc/actions)

Generate PHPDoc comments for Laravel Models including [**database columns**](https://laravel.com/docs/eloquent), [**relationships**](https://laravel.com/docs/eloquent-relationships), [**accessors**](https://laravel.com/docs/eloquent-mutators#accessors-and-mutators), [**query scopes**](https://laravel.com/docs/eloquent#query-scopes) and [**factories**](https://laravel.com/docs/eloquent-factories).

Contents
--------

[](#contents)

- [Installation](#installation)
- [Configuration](#configuration)
- [Features](#features)
- [Testing](#testing)

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

[](#installation)

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

```

#### Laravel &lt;= 10

[](#laravel--10)

If you use a Laravel version lower than 11, you also need to install the `doctrine/dbal` package:

```
composer require doctrine/dbal:^3.0 --dev
```

Configuration
-------------

[](#configuration)

Copy configuration to config folder:

```
php artisan vendor:publish --provider="romanzipp\ModelDoc\Providers\ModelDocServiceProvider"

```

Usage
-----

[](#usage)

```
php artisan model-doc:generate

```

See the [configuration file](config/model-doc.php) for more specific use cases.

### Prepare your models

[](#prepare-your-models)

1. Add the corresponding **table name**
2. Add **relation** methods return **types**
3. Add **accessor** methods return **types**

```
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;

class MyModel extends Model
{
    protected $table = 'models'; // 1. Add the corresponding table name

    public function teams(): HasMany // 2. Add relation methods return types
    {
        return $this->hasMany(Team::class);
    }

    public function getNameAttribute(): string // 3. Add accessor methods return types
    {
        return ucfirst($this->name);
    }
}
```

### Example

[](#example)

```
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

/**
 * @property string $id
 * @property string $title
 * @property string $pretty_title
 * @property string|null $icon
 * @property int $order
 * @property bool $enabled
 * @property array $children
 * @property \Illuminate\Support\Carbon|null $created_at
 * @property \Illuminate\Support\Carbon|null $updated_at
 *
 * @property \Illuminate\Database\Eloquent\Collection|\App\Models\Team[] $teams
 * @property int|null $teams_count
 *
 * @method static \Illuminate\Database\Eloquent\Builder whereTeamName(string $name)
 *
 * @method static \Database\Factoies\MyUserFactory factory($count = null, $state = [])
 */
class MyUser extends Model
{
    use HasFactory;

    protected $table = 'users';

    protected $casts = [
        'children' => 'array',
    ];

    public function teams(): HasMany
    {
        return $this->hasMany(Team::class);
    }

    public function scopeWhereTeamName(Builder $builder, string $name)
    {
        $builder->where('name', $name);
    }

    public function getPrettyTitleAttribute(): string
    {
        return ucfirst($this->title);
    }

    protected static function newFactory()
    {
        return new \Database\Factoies\MyUserFactory();
    }
}
```

### Set custom path

[](#set-custom-path)

You can set a custom base path for the generator using the `usePath` static method.

```
use Illuminate\Support\ServiceProvider;
use romanzipp\ModelDoc\Services\DocumentationGenerator;

class AppServiceProvider extends ServiceProvider
{
    public function register()
    {
        DocumentationGenerator::usePath(fn () => base_path('app/Models'));
    }
}
```

See the [configuration file](config/model-doc.php) for more specific use cases.

### Use verbose mode

[](#use-verbose-mode)

If you get an error when generating the documentation for a model, you can use the `--v` option to get more information about the error.

```
php artisan model-doc:generate --v

```

### Custom database types

[](#custom-database-types)

If (in verbose mode) you get an error like `Unknown database type enum requested`, you can add that custom type mapping in Laravel's `database.php` config file. Laravel uses the [Doctrine DBAL](https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/types.html) package for database types. You can find a list of supported types [here](https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/types.html#mapping-matrix). Laravel provides an example for `timestamp` type mapping [here](https://laravel.com/docs/10.x/migrations#modifying-columns-on-sqlite).

Here is an example for `enum` type mapping in `database.php` config file:

```
'dbal' => [
    'types' => [
        'enum' => Doctrine\DBAL\Types\StringType::class,
    ],
],
```

Features
--------

[](#features)

- Generate `@property` tags from attributes
- Look for attributes type casts
- Do not generate attribute `@property` tag if accessor exists
- Generate `@method` tags from relationships
- Generate `@property` tags from relationships
- Generate `@property` tags from relationship counts
- Generate `@method` tags query scopes
- Generate `@property` tags from accessors
- Only generate `@property-readonly` if accessor has no real attribute or mutator

Testing
-------

[](#testing)

### SQLite

[](#sqlite)

```
./vendor/bin/phpunit

```

### MariaDB

[](#mariadb)

Requires [Lando](https://lando.dev/).

```
lando start
lando phpunit

```

###  Health Score

57

—

FairBetter than 98% of packages

Maintenance74

Regular maintenance activity

Popularity42

Moderate usage in the ecosystem

Community17

Small or concentrated contributor base

Maturity78

Established project with proven stability

 Bus Factor1

Top contributor holds 80.5% 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 ~39 days

Recently: every ~112 days

Total

45

Last Release

203d ago

Major Versions

0.1.2 → 1.0.02021-10-15

1.2.8 → 2.0.02023-05-20

2.2.0 → 3.0.22024-03-19

PHP version history (3 changes)0.0.1PHP ^7.4|^8.0

2.0.0PHP ^8.0

3.0.2PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/309ea408cc915d1d37b370796df57a24ec31f0b65da69f69c650c8983f9c33a6?d=identicon)[romanzipp](/maintainers/romanzipp)

---

Top Contributors

[![romanzipp](https://avatars.githubusercontent.com/u/11266773?v=4)](https://github.com/romanzipp "romanzipp (140 commits)")[![dmitrakovich](https://avatars.githubusercontent.com/u/28905316?v=4)](https://github.com/dmitrakovich "dmitrakovich (15 commits)")[![saulens22](https://avatars.githubusercontent.com/u/9000854?v=4)](https://github.com/saulens22 "saulens22 (14 commits)")[![donatiss](https://avatars.githubusercontent.com/u/6832828?v=4)](https://github.com/donatiss "donatiss (3 commits)")[![joelvh](https://avatars.githubusercontent.com/u/129096?v=4)](https://github.com/joelvh "joelvh (2 commits)")

---

Tags

eloquentidelaravelormphpshowcase

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/romanzipp-laravel-model-doc/health.svg)

```
[![Health](https://phpackages.com/badges/romanzipp-laravel-model-doc/health.svg)](https://phpackages.com/packages/romanzipp-laravel-model-doc)
```

###  Alternatives

[tucker-eric/eloquentfilter

An Eloquent way to filter Eloquent Models

1.8k4.8M26](/packages/tucker-eric-eloquentfilter)[ryangjchandler/orbit

A flat-file database driver for Eloquent.

922256.2k5](/packages/ryangjchandler-orbit)[clickbar/laravel-magellan

This package provides functionality for working with the postgis extension in Laravel.

423715.4k1](/packages/clickbar-laravel-magellan)[fumeapp/modeltyper

Generate TypeScript interfaces from Laravel Models

196277.9k](/packages/fumeapp-modeltyper)[baril/bonsai

An implementation of the Closure Tables pattern for Eloquent.

3593.5k](/packages/baril-bonsai)[toponepercent/baum

Baum is an implementation of the Nested Set pattern for Eloquent models.

3154.7k](/packages/toponepercent-baum)

PHPackages © 2026

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