PHPackages                             boktoso-enterprise/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. boktoso-enterprise/laravel-model-doc

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

boktoso-enterprise/laravel-model-doc
====================================

Laravel Model PHPDoc Generator

v0.0.4(2y ago)06.8k↓92.9%MITPHPPHP ^8.0

Since Jul 3Pushed 2y agoCompare

[ Source](https://github.com/BoktosoEnterprise/Laravel-Model-Doc)[ Packagist](https://packagist.org/packages/boktoso-enterprise/laravel-model-doc)[ GitHub Sponsors](https://github.com/boktoso)[ RSS](/packages/boktoso-enterprise-laravel-model-doc/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (4)Dependencies (10)Versions (5)Used By (0)

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

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

Fork off of [romanzipp/Laravel-Model-Doc](https://github.com/romanzipp/Laravel-Model-Doc)

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 boktoso-enterprise/laravel-model-doc --dev

```

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

[](#configuration)

Copy configuration to config folder:

```
php artisan vendor:publish --provider="boktoso-enterprise\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 BoktosoEnterprise\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

```

### Specify the Model to update

[](#specify-the-model-to-update)

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 --model={modelClass}

```

### 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,
    ],
],
```

Testing
-------

[](#testing)

### SQLite

[](#sqlite)

```
./vendor/bin/phpunit

```

### MariaDB

[](#mariadb)

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

```
lando start
lando phpunit

```

###  Health Score

25

—

LowBetter than 35% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 87.2% 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 ~16 days

Total

4

Last Release

1048d ago

### Community

Maintainers

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

---

Top Contributors

[![romanzipp](https://avatars.githubusercontent.com/u/11266773?v=4)](https://github.com/romanzipp "romanzipp (109 commits)")[![boktoso](https://avatars.githubusercontent.com/u/15949544?v=4)](https://github.com/boktoso "boktoso (7 commits)")[![saulens22](https://avatars.githubusercontent.com/u/9000854?v=4)](https://github.com/saulens22 "saulens22 (7 commits)")[![joelvh](https://avatars.githubusercontent.com/u/129096?v=4)](https://github.com/joelvh "joelvh (2 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[laravel/ai

The official AI SDK for Laravel.

1.0k3.2M200](/packages/laravel-ai)[flarum/core

Delightfully simple forum software.

201.4M2.3k](/packages/flarum-core)[illuminate/queue

The Illuminate Queue package.

21332.6M1.6k](/packages/illuminate-queue)[mike-bronner/laravel-model-caching

Automatic caching for Eloquent models.

2.4k91.9k1](/packages/mike-bronner-laravel-model-caching)[fumeapp/modeltyper

Generate TypeScript interfaces from Laravel Models

198321.1k](/packages/fumeapp-modeltyper)

PHPackages © 2026

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