[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-8131":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":16,"stars7d":17,"stars30d":18,"stars90d":16,"forks30d":16,"starsTrendScore":19,"compositeScore":20,"rankGlobal":10,"rankLanguage":10,"license":21,"archived":22,"fork":22,"defaultBranch":23,"hasWiki":22,"hasPages":22,"topics":24,"createdAt":10,"pushedAt":10,"updatedAt":28,"readmeContent":29,"aiSummary":30,"trendingCount":16,"starSnapshotCount":16,"syncStatus":31,"lastSyncTime":32,"discoverSource":33},8131,"laravel-ide-helper","barryvdh\u002Flaravel-ide-helper","barryvdh","IDE Helper for Laravel","",null,"PHP",14931,1189,254,160,0,11,37,3,44.23,"MIT License",false,"master",[25,26,27],"autocompletion","hacktoberfest","laravel","2026-06-12 02:01:49","# IDE Helper Generator for Laravel\n\n[![Tests](https:\u002F\u002Fgithub.com\u002Fbarryvdh\u002Flaravel-ide-helper\u002Factions\u002Fworkflows\u002Frun-tests.yml\u002Fbadge.svg)](https:\u002F\u002Fgithub.com\u002Fbarryvdh\u002Flaravel-ide-helper\u002Factions)\n[![Packagist License](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FLicence-MIT-blue)](http:\u002F\u002Fchoosealicense.com\u002Flicenses\u002Fmit\u002F)\n[![Latest Stable Version](https:\u002F\u002Fimg.shields.io\u002Fpackagist\u002Fv\u002Fbarryvdh\u002Flaravel-ide-helper?label=Stable)](https:\u002F\u002Fpackagist.org\u002Fpackages\u002Fbarryvdh\u002Flaravel-ide-helper)\n[![Total Downloads](https:\u002F\u002Fimg.shields.io\u002Fpackagist\u002Fdt\u002Fbarryvdh\u002Flaravel-ide-helper?label=Downloads)](https:\u002F\u002Fpackagist.org\u002Fpackages\u002Fbarryvdh\u002Flaravel-ide-helper)\n[![Fruitcake](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FPowered%20By-Fruitcake-b2bc35.svg)](https:\u002F\u002Ffruitcake.nl\u002F)\n\n**Complete PHPDocs, directly from the source**\n\nThis package generates helper files that enable your IDE to provide accurate autocompletion.\nGeneration is done based on the files in your project, so they are always up-to-date.\n\nThe 3.x branch supports Laravel 10 and later. For older version, use the 2.x releases.\n\n- [Installation](#installation)\n- [Usage](#usage)\n  - [Automatic PHPDoc generation for Laravel Facades](#automatic-phpdoc-generation-for-laravel-facades)\n  - [Automatic PHPDocs for models](#automatic-phpdocs-for-models)\n    - [Model Directories](#model-directories)\n    - [Ignore Models](#ignore-models)\n    - [Model Hooks](#model-hooks)\n  - [Automatic PHPDocs generation for Laravel Fluent methods](#automatic-phpdocs-generation-for-laravel-fluent-methods)\n  - [Auto-completion for factory builders](#auto-completion-for-factory-builders)\n  - [PhpStorm Meta for Container instances](#phpstorm-meta-for-container-instances)\n- [License](#license)\n\n## Installation\n\nRequire this package with composer using the following command:\n\n```bash\ncomposer require --dev barryvdh\u002Flaravel-ide-helper\n```\n\n\n## Usage\n\n### TL;DR\n\nRun this to generate autocompletion for Facades. This creates _ide_helper.php\n\n```\nphp artisan ide-helper:generate\n```\n\nRun this to add phpdocs for your models. Add -RW to Reset existing phpdocs and Write to the models directly.\n```\nphp artisan ide-helper:models -RW\n```\n\nIf you don't want the full _ide_helper.php file, you can run add `--write-eloquent-helper` to the model command to generate small version, which is required for the `@mixin \\Eloquent` to be able to add the QueryBuilder methods.\n\nIf you don't want to add all the phpdocs to your Models directly, you can use `--nowrite` to create a separate file. The  `--write-mixin` option can be used to only add a `@mixin` to your models, but add the generated phpdocs in a separate file. This avoids having the results marked as duplicate.\n\n\n_Check out [this Laracasts video](https:\u002F\u002Flaracasts.com\u002Fseries\u002Fhow-to-be-awesome-in-phpstorm\u002Fepisodes\u002F15) for a quick introduction\u002Fexplanation!_\n\n- `php artisan ide-helper:generate` - [PHPDoc generation for Laravel Facades ](#automatic-phpdoc-generation-for-laravel-facades)\n- `php artisan ide-helper:models` - [PHPDocs for models](#automatic-phpdocs-for-models)\n- `php artisan ide-helper:meta` - [PhpStorm Meta file](#phpstorm-meta-for-container-instances)\n\n\n> Note: You do need CodeComplice for Sublime Text: https:\u002F\u002Fgithub.com\u002Fspectacles\u002FCodeComplice\n\n### Automatic PHPDoc generation for Laravel Facades\n\nYou can now re-generate the docs yourself (for future updates)\n\n```bash\nphp artisan ide-helper:generate\n```\n\nThis will generate the file `_ide_helper.php` which is expected to be additionally parsed by your IDE for autocomplete. You can use the config `filename` to change its name.\n\nYou can configure your `composer.json` to do this each time you update your dependencies:\n\n```js\n\"scripts\": {\n    \"post-update-cmd\": [\n        \"Illuminate\\\\Foundation\\\\ComposerScripts::postUpdate\",\n        \"@php artisan ide-helper:generate\",\n        \"@php artisan ide-helper:meta\"\n    ]\n},\n```\n\nYou can also publish the config file to change implementations (ie. interface to specific class) or set defaults for `--helpers`.\n\n```bash\nphp artisan vendor:publish --provider=\"Barryvdh\\LaravelIdeHelper\\IdeHelperServiceProvider\" --tag=config\n```\n\nThe generator tries to identify the real class, but if it cannot be found, you can define it in the config file.\n\nSome classes need a working database connection. If you do not have a default working connection, some facades will not be included.\nYou can use an in-memory SQLite driver by adding the `-M` option.\n\nIf you use [real-time facades](https:\u002F\u002Flaravel.com\u002Fdocs\u002Fmaster\u002Ffacades#real-time-facades) in your app, those will also be included in the generated file using a `@mixin` annotation and extending the original class underneath the facade. \n\n> **Note**: this feature uses the generated real-time facades files in the `storage\u002Fframework\u002Fcache` folder. Those files are generated on-demand as you use the real-time facade, so if the framework has not generated that first, it will not be included in the helper file. Run the route\u002Fcommand\u002Fcode first and then regenerate the helper file and this time the real-time facade will be included in it.\n\nYou can choose to include helper files. This is not enabled by default, but you can override it with the `--helpers (-H)` option.\nThe `Illuminate\u002FSupport\u002Fhelpers.php` is already set up, but you can add\u002Fremove your own files in the config file.\n\n### Automatic PHPDoc generation for macros and mixins\n\nThis package can generate PHPDocs for macros and mixins which will be added to the `_ide_helper.php` file.\n\nBut this only works if you use type hinting when declaring a macro.\n\n```php\nStr::macro('concat', function(string $str1, string $str2) : string {\n    return $str1 . $str2;\n});\n```\n\n### Automatic PHPDocs for models\n\nIf you don't want to write your properties yourself, you can use the command `php artisan ide-helper:models` to generate\nPHPDocs, based on table columns, relations and getters\u002Fsetters.\n\n> Note: this command requires a working database connection to introspect the table of each model\n\nBy default, you are asked to overwrite or write to a separate file (`_ide_helper_models.php`).\nYou can write the comments directly to your Model file, using the `--write (-W)` option, or\nforce to not write with `--nowrite (-N)`.\n\nAlternatively using the `--write-mixin (-M)` option will only add a mixin tag to your Model file,\nwriting the rest in (`_ide_helper_models.php`).\nThe class name will be different from the model, avoiding the IDE duplicate annoyance.\n\n> Please make sure to back up your models, before writing the info.\n\n> You need the _ide_helper.php file to add the QueryBuilder methods. You can add --write-eloquent-helper\u002F-E to generate a minimal version. If this file does not exist, you will be prompted for it.\n\nWriting to the models should keep the existing comments and only append new properties\u002Fmethods. It will not update changed properties\u002Fmethods.\n\nWith the `--reset (-R)` option, the whole existing PHPDoc is replaced, including any comments that have been made.\n\n```bash\nphp artisan ide-helper:models \"App\\Models\\Post\"\n```\n\n```php\n\u002F**\n * App\\Models\\Post\n *\n * @property integer $id\n * @property integer $author_id\n * @property string $title\n * @property string $text\n * @property \\Illuminate\\Support\\Carbon $created_at\n * @property \\Illuminate\\Support\\Carbon $updated_at\n * @property-read \\User $author\n * @property-read \\Illuminate\\Database\\Eloquent\\Collection|\\Comment[] $comments\n * @method static \\Illuminate\\Database\\Eloquent\\Builder\u003Cstatic>|\\App\\Models\\Post newModelQuery()\n * @method static \\Illuminate\\Database\\Eloquent\\Builder\u003Cstatic>|\\App\\Models\\Post newQuery()\n * @method static \\Illuminate\\Database\\Eloquent\\Builder\u003Cstatic>|\\App\\Models\\Post query()\n * @method static \\Illuminate\\Database\\Eloquent\\Builder\u003Cstatic>|\\App\\Models\\Post whereTitle($value)\n * @method static \\Illuminate\\Database\\Eloquent\\Builder\u003Cstatic>|\\App\\Models\\Post forAuthors(\\User ...$authors)\n * …\n *\u002F\n```\n\nWith the `--write-mixin (-M)` option\n```php\n\u002F**\n * …\n * @mixin IdeHelperPost\n *\u002F\n```\n\n#### Model Directories\n\nBy default, models in `app\u002Fmodels` are scanned. The optional argument tells what models to use (also outside app\u002Fmodels).\n\n```bash\nphp artisan ide-helper:models \"App\\Models\\Post\" \"App\\Models\\User\"\n```\n\nYou can also scan a different directory, using the `--dir` option (relative from the base path):\n\n```bash\nphp artisan ide-helper:models --dir=\"path\u002Fto\u002Fmodels\" --dir=\"app\u002Fsrc\u002FModel\"\n```\n\nYou can publish the config file (`php artisan vendor:publish`) and set the default directories.\n\n#### Ignore Models\n\nModels can be ignored using the `--ignore (-I)` option\n\n```bash\nphp artisan ide-helper:models --ignore=\"App\\Models\\Post,App\\Models\\User\"\n```\n\nOr can be ignored by setting the `ignored_models` config\n\n```php\n'ignored_models' => [\n    App\\Post::class,\n    Api\\User::class\n],\n```\n\n#### Magic `where*` methods\n\nEloquent allows calling `where\u003CAttribute>` on your models, e.g. `Post::whereTitle(…)` and automatically translates this to e.g. `Post::where('title', '=', '…')`.\n\nIf for some reason it's undesired to have them generated (one for each column), you can disable this via config `write_model_magic_where` and setting it to `false`.\n\n#### Magic `*_count` and `*_exists` properties\n\nYou may use the [`::withCount`](https:\u002F\u002Flaravel.com\u002Fdocs\u002Fmaster\u002Feloquent-relationships#counting-related-models) and [`::withExists`](https:\u002F\u002Flaravel.com\u002Fdocs\u002Fmaster\u002Feloquent-relationships#other-aggregate-functions) methods to count the number results from a relationship without actually loading them. Those results are then placed in attributes following the `\u003Ccolumnname>_count` and `\u003Ccolumnname>_exists` convention.\n\nBy default, these attributes are generated in the phpdoc. You can turn them off by setting the config `write_model_relation_count_properties` and `write_model_relation_exists_properties` to `false`.\n\n#### Generics annotations\n\nLaravel 9 introduced generics annotations in DocBlocks for collections. PhpStorm 2022.3 and above support the use of generics annotations within `@property` and `@property-read` declarations in DocBlocks, e.g. `Collection\u003CUser>` instead of `Collection|User[]`.\n\nThese can be disabled by setting the config `use_generics_annotations` to `false`.\n\n#### Support `@comment` based on DocBlock\n\nIn order to better support IDEs, relations and getters\u002Fsetters can also add a comment to a property like table columns. Therefore a custom docblock `@comment` is used:\n```php\nclass Users extends Model\n{\n    \u002F**\n     * @comment Get User's full name\n     *\n     * @return string\n     *\u002F\n    public function getFullNameAttribute(): string\n    {\n        return $this->first_name . ' ' .$this->last_name ;\n    }\n}\n\n\u002F\u002F => after generate models\n\n\u002F**\n * App\\Models\\Users\n * \n * @property-read string $full_name Get User's full name\n * …\n *\u002F\n```\n\n#### Dedicated Eloquent Builder methods\n\nA new method to the eloquent models was added called `newEloquentBuilder` [Reference](https:\u002F\u002Ftimacdonald.me\u002Fdedicated-eloquent-model-query-builders\u002F) where we can \nadd support for creating a new dedicated class instead of using local scopes in the model itself.\n\nIf for some reason it's undesired to have them generated (one for each column), you can disable this via config `write_model_external_builder_methods` and setting it to `false`.\n\n#### Custom Relationship Types\n\nIf you are using relationships not built into Laravel you will need to specify the name and returning class in the config to get proper generation.\n\n```php\n'additional_relation_types' => [\n    'externalHasMany' => \\My\\Package\\externalHasMany::class\n],\n```\n\nFound relationships will typically generate a return value based on the name of the relationship.\n\nIf your custom relationships don't follow this traditional naming scheme you can define its return type manually. The available options are `many` and `morphTo`.\n\n```php\n'additional_relation_return_types' => [\n    'externalHasMultiple' => 'many'\n],\n```\n\n#### Model Hooks\n\nIf you need additional information on your model from sources that are not handled by default, you can hook in to the\n generation process with model hooks to add extra information on the fly.\n Simply create a class that implements `ModelHookInterface` and add it to the `model_hooks` array in the config:\n \n ```php\n'model_hooks' => [\n    MyCustomHook::class,\n],\n```\n\nThe `run` method will be called during generation for every model and receives the current running `ModelsCommand` and the current `Model`, e.g.:\n\n```php\nclass MyCustomHook implements ModelHookInterface\n{\n    public function run(ModelsCommand $command, Model $model): void\n    {\n        if (! $model instanceof MyModel) {\n            return;\n        }\n\n        $command->setProperty('custom', 'string', true, false, 'My custom property');\n        $command->unsetMethod('method');\n        $command->setMethod('method', $command->getMethodType($model, '\\Some\\Class'), ['$param']);\n    }\n}\n```\n\n```php\n\u002F**\n * MyModel\n *\n * @property integer $id\n * @property-read string $custom\n```\n\n### Automatic PHPDocs generation for Laravel Fluent methods\n\nIf you need PHPDocs support for Fluent methods in migration, for example\n\n```php\n$table->string(\"somestring\")->nullable()->index();\n```\n\nAfter publishing vendor, simply change the `include_fluent` line in your `config\u002Fide-helper.php` file into:\n\n```php\n'include_fluent' => true,\n```\n\nThen run `php artisan ide-helper:generate`, you will now see all Fluent methods recognized by your IDE.\n\n### Auto-completion for factory builders\n\nIf you would like the `factory()->create()` and `factory()->make()` methods to return the correct model class,\nyou can enable custom factory builders with the `include_factory_builders` line in your `config\u002Fide-helper.php` file.\nDeprecated for Laravel 8 or latest.\n\n```php\n'include_factory_builders' => true,\n```\n\nFor this to work, you must also publish the PhpStorm Meta file (see below).\n\n## PhpStorm Meta for Container instances\n\nIt's possible to generate a PhpStorm meta file to [add support for factory design pattern](https:\u002F\u002Fwww.jetbrains.com\u002Fhelp\u002Fphpstorm\u002Fide-advanced-metadata.html).\nFor Laravel, this means we can make PhpStorm understand what kind of object we are resolving from the IoC Container.\nFor example, `events` will return an `Illuminate\\Events\\Dispatcher` object,\nso with the meta file you can call `app('events')` and it will autocomplete the Dispatcher methods.\n\n```bash\nphp artisan ide-helper:meta\n```\n\n```php\napp('events')->fire();\n\\App::make('events')->fire();\n\n\u002F** @var \\Illuminate\\Foundation\\Application $app *\u002F\n$app->make('events')->fire();\n\n\u002F\u002F When the key is not found, it uses the argument as class name\napp('App\\SomeClass');\n\u002F\u002F Also works with\napp(App\\SomeClass::class);\n```\n\n> Note: You might need to restart PhpStorm and make sure `.phpstorm.meta.php` is indexed.\n\n> Note: When you receive a FatalException: class not found, check your config\n> (for example, remove S3 as cloud driver when you don't have S3 configured. Remove Redis ServiceProvider when you don't use it).\n\nYou can change the generated filename via the config `meta_filename`. This can be useful for cases where you want to take advantage of PhpStorm's support of the _directory_ `.phpstorm.meta.php\u002F`: all files placed there are parsed, should you want to provide additional files to PhpStorm.\n\n## License\n\nThe Laravel IDE Helper Generator is open-sourced software licensed under the [MIT license](http:\u002F\u002Fopensource.org\u002Flicenses\u002FMIT)\n\n","barryvdh\u002Flaravel-ide-helper 是一个为 Laravel 框架提供 IDE 支持的工具，主要功能是自动生成 PHPDoc 以增强开发环境中的代码自动补全能力。它能够基于项目文件生成辅助文件，确保这些文件始终保持最新状态，从而帮助开发者更高效地编写代码。该工具支持自动为 Laravel 的 Facade、模型以及 Fluent 方法生成详细的 PHPDoc，并且还提供了对工厂构建器和容器实例的智能提示支持。适用于使用 Laravel 进行 Web 开发的所有场景，特别是当团队成员需要在复杂的项目结构中快速定位和理解代码时。",2,"2026-06-11 03:16:18","top_language"]