{"id":16078456,"url":"https://github.com/romanzipp/laravel-model-doc","last_synced_at":"2025-10-05T17:05:56.054Z","repository":{"id":40395093,"uuid":"329844512","full_name":"romanzipp/Laravel-Model-Doc","owner":"romanzipp","description":"📝 Generate PHPDoc comments for Laravel Models","archived":false,"fork":false,"pushed_at":"2025-06-27T14:07:07.000Z","size":109,"stargazers_count":29,"open_issues_count":8,"forks_count":9,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-27T19:38:47.793Z","etag":null,"topics":["eloquent","ide","laravel","orm","php","showcase"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/romanzipp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":"romanzipp"}},"created_at":"2021-01-15T07:51:12.000Z","updated_at":"2025-06-26T15:42:29.000Z","dependencies_parsed_at":"2025-09-27T19:31:56.963Z","dependency_job_id":null,"html_url":"https://github.com/romanzipp/Laravel-Model-Doc","commit_stats":{"total_commits":89,"total_committers":4,"mean_commits":22.25,"dds":0.0898876404494382,"last_synced_commit":"175bfd00d175117c062beb8fe29c2bd847ea7b76"},"previous_names":[],"tags_count":44,"template":false,"template_full_name":null,"purl":"pkg:github/romanzipp/Laravel-Model-Doc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/romanzipp%2FLaravel-Model-Doc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/romanzipp%2FLaravel-Model-Doc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/romanzipp%2FLaravel-Model-Doc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/romanzipp%2FLaravel-Model-Doc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/romanzipp","download_url":"https://codeload.github.com/romanzipp/Laravel-Model-Doc/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/romanzipp%2FLaravel-Model-Doc/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278486308,"owners_count":25994945,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-05T02:00:06.059Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["eloquent","ide","laravel","orm","php","showcase"],"created_at":"2024-10-09T10:12:56.771Z","updated_at":"2025-10-05T17:05:56.012Z","avatar_url":"https://github.com/romanzipp.png","language":"PHP","funding_links":["https://github.com/sponsors/romanzipp"],"categories":[],"sub_categories":[],"readme":"# Laravel Model PHPDoc Generator\n\n[![Latest Stable Version](https://img.shields.io/packagist/v/romanzipp/Laravel-Model-Doc.svg?style=flat-square)](https://packagist.org/packages/romanzipp/laravel-model-doc)\n[![Total Downloads](https://img.shields.io/packagist/dt/romanzipp/Laravel-Model-Doc.svg?style=flat-square)](https://packagist.org/packages/romanzipp/laravel-model-doc)\n[![License](https://img.shields.io/packagist/l/romanzipp/Laravel-Model-Doc.svg?style=flat-square)](https://packagist.org/packages/romanzipp/laravel-model-doc)\n[![GitHub Build Status](https://img.shields.io/github/actions/workflow/status/romanzipp/Laravel-Model-Doc/tests.yml?branch=master\u0026label=tests\u0026style=flat-square)](https://github.com/romanzipp/Laravel-Model-Doc/actions)\n\nGenerate 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).\n\n## Contents\n\n- [Installation](#installation)\n- [Configuration](#configuration)\n- [Features](#features)\n- [Testing](#testing)\n\n## Installation\n\n```\ncomposer require romanzipp/laravel-model-doc --dev\n```\n\n#### Laravel \u003c= 10\n\nIf you use a Laravel version lower than 11, you also need to install the `doctrine/dbal` package:\n\n```shell\ncomposer require doctrine/dbal:^3.0 --dev\n```\n\n## Configuration\n\nCopy configuration to config folder:\n\n```\nphp artisan vendor:publish --provider=\"romanzipp\\ModelDoc\\Providers\\ModelDocServiceProvider\"\n```\n\n## Usage\n\n```\nphp artisan model-doc:generate\n```\n\nSee the [configuration file](config/model-doc.php) for more specific use cases.\n\n### Prepare your models\n\n1. Add the corresponding **table name**\n2. Add **relation** methods return **types** \n3. Add **accessor** methods return **types**\n\n```php\nuse Illuminate\\Database\\Eloquent\\Model;\nuse Illuminate\\Database\\Eloquent\\Relations\\HasMany;\n\nclass MyModel extends Model\n{\n    protected $table = 'models'; // 1. Add the corresponding table name\n    \n    public function teams(): HasMany // 2. Add relation methods return types\n    {\n        return $this-\u003ehasMany(Team::class);\n    }\n    \n    public function getNameAttribute(): string // 3. Add accessor methods return types\n    {\n        return ucfirst($this-\u003ename);\n    }\n}\n```\n\n### Example\n\n```php\nuse Illuminate\\Database\\Eloquent\\Builder;\nuse Illuminate\\Database\\Eloquent\\Factories\\HasFactory;\nuse Illuminate\\Database\\Eloquent\\Model;\n\n/**\n * @property string $id\n * @property string $title\n * @property string $pretty_title\n * @property string|null $icon\n * @property int $order\n * @property bool $enabled\n * @property array $children\n * @property \\Illuminate\\Support\\Carbon|null $created_at\n * @property \\Illuminate\\Support\\Carbon|null $updated_at\n *\n * @property \\Illuminate\\Database\\Eloquent\\Collection|\\App\\Models\\Team[] $teams\n * @property int|null $teams_count\n *\n * @method static \\Illuminate\\Database\\Eloquent\\Builder whereTeamName(string $name)\n * \n * @method static \\Database\\Factoies\\MyUserFactory\u003cself\u003e factory($count = null, $state = [])\n */\nclass MyUser extends Model\n{\n    use HasFactory;\n\n    protected $table = 'users';\n\n    protected $casts = [\n        'children' =\u003e 'array',\n    ];\n\n    public function teams(): HasMany\n    {\n        return $this-\u003ehasMany(Team::class);\n    }\n\n    public function scopeWhereTeamName(Builder $builder, string $name)\n    {\n        $builder-\u003ewhere('name', $name);\n    }\n\n    public function getPrettyTitleAttribute(): string\n    {\n        return ucfirst($this-\u003etitle);\n    }\n    \n    protected static function newFactory()\n    {\n        return new \\Database\\Factoies\\MyUserFactory();\n    }\n}\n```\n\n### Set custom path\n\nYou can set a custom base path for the generator using the `usePath` static method.\n\n```php\nuse Illuminate\\Support\\ServiceProvider;\nuse romanzipp\\ModelDoc\\Services\\DocumentationGenerator;\n\nclass AppServiceProvider extends ServiceProvider\n{\n    public function register()\n    {\n        DocumentationGenerator::usePath(fn () =\u003e base_path('app/Models'));\n    }\n}\n```\n\nSee the [configuration file](config/model-doc.php) for more specific use cases.\n\n### Use verbose mode\n\nIf you get an error when generating the documentation for a model, you can use the `--v` option to get more information about the error.\n\n```\nphp artisan model-doc:generate --v\n```\n\n### Custom database types\n\nIf (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).\nLaravel provides an example for `timestamp` type mapping [here](https://laravel.com/docs/10.x/migrations#modifying-columns-on-sqlite).\n\nHere is an example for `enum` type mapping in `database.php` config file:\n\n```php\n'dbal' =\u003e [\n    'types' =\u003e [\n        'enum' =\u003e Doctrine\\DBAL\\Types\\StringType::class,\n    ],\n],\n```\n\n## Features\n\n- [x] Generate `@property` tags from attributes\n- [x] Look for attributes type casts\n- [x] Do not generate attribute `@property` tag if accessor exists\n- [x] Generate `@method` tags from relationships\n- [x] Generate `@property` tags from relationships\n- [x] Generate `@property` tags from relationship counts\n- [x] Generate `@method` tags query scopes\n- [x] Generate `@property` tags from accessors\n- [ ] Only generate `@property-readonly` if accessor has no real attribute or mutator\n\n## Testing\n\n### SQLite\n\n```\n./vendor/bin/phpunit\n```\n\n### MariaDB\n\nRequires [Lando](https://lando.dev/).\n\n```\nlando start\nlando phpunit\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fromanzipp%2Flaravel-model-doc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fromanzipp%2Flaravel-model-doc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fromanzipp%2Flaravel-model-doc/lists"}