PHPackages                             barryvdh/laravel-ide-helper - 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. barryvdh/laravel-ide-helper

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

barryvdh/laravel-ide-helper
===========================

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

v3.7.0(2mo ago)14.9k123.0M—1.5%1.2k[159 issues](https://github.com/barryvdh/laravel-ide-helper/issues)[32 PRs](https://github.com/barryvdh/laravel-ide-helper/pulls)20MITPHPPHP ^8.2CI passing

Since May 23Pushed 1w ago254 watchersCompare

[ Source](https://github.com/barryvdh/laravel-ide-helper)[ Packagist](https://packagist.org/packages/barryvdh/laravel-ide-helper)[ Fund](https://fruitcake.nl)[ GitHub Sponsors](https://github.com/barryvdh)[ RSS](/packages/barryvdh-laravel-ide-helper/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (31)Versions (140)Used By (20)

IDE Helper Generator for Laravel
================================

[](#ide-helper-generator-for-laravel)

[![Tests](https://github.com/barryvdh/laravel-ide-helper/actions/workflows/run-tests.yml/badge.svg)](https://github.com/barryvdh/laravel-ide-helper/actions)[![Packagist License](https://camo.githubusercontent.com/e60623f508586f049d48cfb8396ee411b0c9bc3be174381a1893c37462a3c1e5/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e63652d4d49542d626c7565)](http://choosealicense.com/licenses/mit/)[![Latest Stable Version](https://camo.githubusercontent.com/dcb4de7c9f24677cdf184e96d9d96521b17aa2f5b4c45b13d0d97b78fd2a320e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f62617272797664682f6c61726176656c2d6964652d68656c7065723f6c6162656c3d537461626c65)](https://packagist.org/packages/barryvdh/laravel-ide-helper)[![Total Downloads](https://camo.githubusercontent.com/e8f96fccecdb1ce4a95101132d9833fdfa76bab6458b6a81de9102a2776e9cdc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f62617272797664682f6c61726176656c2d6964652d68656c7065723f6c6162656c3d446f776e6c6f616473)](https://packagist.org/packages/barryvdh/laravel-ide-helper)[![Fruitcake](https://camo.githubusercontent.com/28d7584b52e33d7b4ffb6b1bef8b89b6e598adb45c8c0d5f80349c1c304f385e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f506f776572656425323042792d467275697463616b652d6232626333352e737667)](https://fruitcake.nl/)

**Complete PHPDocs, directly from the source**

This package generates helper files that enable your IDE to provide accurate autocompletion. Generation is done based on the files in your project, so they are always up-to-date.

The 3.x branch supports Laravel 10 and later. For older version, use the 2.x releases.

- [Installation](#installation)
- [Usage](#usage)
    - [Automatic PHPDoc generation for Laravel Facades](#automatic-phpdoc-generation-for-laravel-facades)
    - [Automatic PHPDocs for models](#automatic-phpdocs-for-models)
        - [Model Directories](#model-directories)
        - [Ignore Models](#ignore-models)
        - [Model Hooks](#model-hooks)
    - [Automatic PHPDocs generation for Laravel Fluent methods](#automatic-phpdocs-generation-for-laravel-fluent-methods)
    - [Auto-completion for factory builders](#auto-completion-for-factory-builders)
    - [PhpStorm Meta for Container instances](#phpstorm-meta-for-container-instances)
- [License](#license)

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

[](#installation)

Require this package with composer using the following command:

```
composer require --dev barryvdh/laravel-ide-helper
```

Usage
-----

[](#usage)

### TL;DR

[](#tldr)

Run this to generate autocompletion for Facades. This creates \_ide\_helper.php

```
php artisan ide-helper:generate

```

Run this to add phpdocs for your models. Add -RW to Reset existing phpdocs and Write to the models directly.

```
php artisan ide-helper:models -RW

```

If 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.

If 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.

*Check out [this Laracasts video](https://laracasts.com/series/how-to-be-awesome-in-phpstorm/episodes/15) for a quick introduction/explanation!*

- `php artisan ide-helper:generate` - [PHPDoc generation for Laravel Facades ](#automatic-phpdoc-generation-for-laravel-facades)
- `php artisan ide-helper:models` - [PHPDocs for models](#automatic-phpdocs-for-models)
- `php artisan ide-helper:meta` - [PhpStorm Meta file](#phpstorm-meta-for-container-instances)

> Note: You do need CodeComplice for Sublime Text:

### Automatic PHPDoc generation for Laravel Facades

[](#automatic-phpdoc-generation-for-laravel-facades)

You can now re-generate the docs yourself (for future updates)

```
php artisan ide-helper:generate
```

This 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.

You can configure your `composer.json` to do this each time you update your dependencies:

```
"scripts": {
    "post-update-cmd": [
        "Illuminate\\Foundation\\ComposerScripts::postUpdate",
        "@php artisan ide-helper:generate",
        "@php artisan ide-helper:meta"
    ]
},
```

You can also publish the config file to change implementations (ie. interface to specific class) or set defaults for `--helpers`.

```
php artisan vendor:publish --provider="Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider" --tag=config
```

The generator tries to identify the real class, but if it cannot be found, you can define it in the config file.

Some classes need a working database connection. If you do not have a default working connection, some facades will not be included. You can use an in-memory SQLite driver by adding the `-M` option.

If you use [real-time facades](https://laravel.com/docs/master/facades#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.

> **Note**: this feature uses the generated real-time facades files in the `storage/framework/cache` 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/command/code first and then regenerate the helper file and this time the real-time facade will be included in it.

You can choose to include helper files. This is not enabled by default, but you can override it with the `--helpers (-H)` option. The `Illuminate/Support/helpers.php` is already set up, but you can add/remove your own files in the config file.

### Automatic PHPDoc generation for macros and mixins

[](#automatic-phpdoc-generation-for-macros-and-mixins)

This package can generate PHPDocs for macros and mixins which will be added to the `_ide_helper.php` file.

But this only works if you use type hinting when declaring a macro.

```
Str::macro('concat', function(string $str1, string $str2) : string {
    return $str1 . $str2;
});
```

### Automatic PHPDocs for models

[](#automatic-phpdocs-for-models)

If you don't want to write your properties yourself, you can use the command `php artisan ide-helper:models` to generate PHPDocs, based on table columns, relations and getters/setters.

> Note: this command requires a working database connection to introspect the table of each model

By default, you are asked to overwrite or write to a separate file (`_ide_helper_models.php`). You can write the comments directly to your Model file, using the `--write (-W)` option, or force to not write with `--nowrite (-N)`.

Alternatively using the `--write-mixin (-M)` option will only add a mixin tag to your Model file, writing the rest in (`_ide_helper_models.php`). The class name will be different from the model, avoiding the IDE duplicate annoyance.

> Please make sure to back up your models, before writing the info.

> You need the \_ide\_helper.php file to add the QueryBuilder methods. You can add --write-eloquent-helper/-E to generate a minimal version. If this file does not exist, you will be prompted for it.

Writing to the models should keep the existing comments and only append new properties/methods. It will not update changed properties/methods.

With the `--reset (-R)` option, the whole existing PHPDoc is replaced, including any comments that have been made.

```
php artisan ide-helper:models "App\Models\Post"
```

```
/**
 * App\Models\Post
 *
 * @property integer $id
 * @property integer $author_id
 * @property string $title
 * @property string $text
 * @property \Illuminate\Support\Carbon $created_at
 * @property \Illuminate\Support\Carbon $updated_at
 * @property-read \User $author
 * @property-read \Illuminate\Database\Eloquent\Collection|\Comment[] $comments
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Post newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Post newQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Post query()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Post whereTitle($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Post forAuthors(\User ...$authors)
 * …
 */
```

With the `--write-mixin (-M)` option

```
/**
 * …
 * @mixin IdeHelperPost
 */
```

#### Model Directories

[](#model-directories)

By default, models in `app/models` are scanned. The optional argument tells what models to use (also outside app/models).

```
php artisan ide-helper:models "App\Models\Post" "App\Models\User"
```

You can also scan a different directory, using the `--dir` option (relative from the base path):

```
php artisan ide-helper:models --dir="path/to/models" --dir="app/src/Model"
```

You can publish the config file (`php artisan vendor:publish`) and set the default directories.

#### Ignore Models

[](#ignore-models)

Models can be ignored using the `--ignore (-I)` option

```
php artisan ide-helper:models --ignore="App\Models\Post,App\Models\User"
```

Or can be ignored by setting the `ignored_models` config

```
'ignored_models' => [
    App\Post::class,
    Api\User::class
],
```

#### Magic `where*` methods

[](#magic-where-methods)

Eloquent allows calling `where` on your models, e.g. `Post::whereTitle(…)` and automatically translates this to e.g. `Post::where('title', '=', '…')`.

If 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`.

#### Magic `*_count` and `*_exists` properties

[](#magic-_count-and-_exists-properties)

You may use the [`::withCount`](https://laravel.com/docs/master/eloquent-relationships#counting-related-models) and [`::withExists`](https://laravel.com/docs/master/eloquent-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 `_count` and `_exists` convention.

By 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`.

#### Generics annotations

[](#generics-annotations)

Laravel 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` instead of `Collection|User[]`.

These can be disabled by setting the config `use_generics_annotations` to `false`.

#### Support `@comment` based on DocBlock

[](#support-comment-based-on-docblock)

In order to better support IDEs, relations and getters/setters can also add a comment to a property like table columns. Therefore a custom docblock `@comment` is used:

```
class Users extends Model
{
    /**
     * @comment Get User's full name
     *
     * @return string
     */
    public function getFullNameAttribute(): string
    {
        return $this->first_name . ' ' .$this->last_name ;
    }
}

// => after generate models

/**
 * App\Models\Users
 *
 * @property-read string $full_name Get User's full name
 * …
 */
```

#### Dedicated Eloquent Builder methods

[](#dedicated-eloquent-builder-methods)

A new method to the eloquent models was added called `newEloquentBuilder` [Reference](https://timacdonald.me/dedicated-eloquent-model-query-builders/) where we can add support for creating a new dedicated class instead of using local scopes in the model itself.

If 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`.

#### Custom Relationship Types

[](#custom-relationship-types)

If 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.

```
'additional_relation_types' => [
    'externalHasMany' => \My\Package\externalHasMany::class
],
```

Found relationships will typically generate a return value based on the name of the relationship.

If your custom relationships don't follow this traditional naming scheme you can define its return type manually. The available options are `many` and `morphTo`.

```
'additional_relation_return_types' => [
    'externalHasMultiple' => 'many'
],
```

#### Model Hooks

[](#model-hooks)

If you need additional information on your model from sources that are not handled by default, you can hook in to the generation process with model hooks to add extra information on the fly. Simply create a class that implements `ModelHookInterface` and add it to the `model_hooks` array in the config:

```
'model_hooks' => [
   MyCustomHook::class,
],
```

The `run` method will be called during generation for every model and receives the current running `ModelsCommand` and the current `Model`, e.g.:

```
class MyCustomHook implements ModelHookInterface
{
    public function run(ModelsCommand $command, Model $model): void
    {
        if (! $model instanceof MyModel) {
            return;
        }

        $command->setProperty('custom', 'string', true, false, 'My custom property');
        $command->unsetMethod('method');
        $command->setMethod('method', $command->getMethodType($model, '\Some\Class'), ['$param']);
    }
}
```

```
/**
 * MyModel
 *
 * @property integer $id
 * @property-read string $custom
```

### Automatic PHPDocs generation for Laravel Fluent methods

[](#automatic-phpdocs-generation-for-laravel-fluent-methods)

If you need PHPDocs support for Fluent methods in migration, for example

```
$table->string("somestring")->nullable()->index();
```

After publishing vendor, simply change the `include_fluent` line in your `config/ide-helper.php` file into:

```
'include_fluent' => true,
```

Then run `php artisan ide-helper:generate`, you will now see all Fluent methods recognized by your IDE.

### Auto-completion for factory builders

[](#auto-completion-for-factory-builders)

If you would like the `factory()->create()` and `factory()->make()` methods to return the correct model class, you can enable custom factory builders with the `include_factory_builders` line in your `config/ide-helper.php` file. Deprecated for Laravel 8 or latest.

```
'include_factory_builders' => true,
```

For this to work, you must also publish the PhpStorm Meta file (see below).

PhpStorm Meta for Container instances
-------------------------------------

[](#phpstorm-meta-for-container-instances)

It's possible to generate a PhpStorm meta file to [add support for factory design pattern](https://www.jetbrains.com/help/phpstorm/ide-advanced-metadata.html). For Laravel, this means we can make PhpStorm understand what kind of object we are resolving from the IoC Container. For example, `events` will return an `Illuminate\Events\Dispatcher` object, so with the meta file you can call `app('events')` and it will autocomplete the Dispatcher methods.

```
php artisan ide-helper:meta
```

```
app('events')->fire();
\App::make('events')->fire();

/** @var \Illuminate\Foundation\Application $app */
$app->make('events')->fire();

// When the key is not found, it uses the argument as class name
app('App\SomeClass');
// Also works with
app(App\SomeClass::class);
```

> Note: You might need to restart PhpStorm and make sure `.phpstorm.meta.php` is indexed.

> Note: When you receive a FatalException: class not found, check your config (for example, remove S3 as cloud driver when you don't have S3 configured. Remove Redis ServiceProvider when you don't use it).

You 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/`: all files placed there are parsed, should you want to provide additional files to PhpStorm.

License
-------

[](#license)

The Laravel IDE Helper Generator is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT)

###  Health Score

87

—

ExcellentBetter than 100% of packages

Maintenance93

Actively maintained with recent releases

Popularity88

Widely adopted with strong download metrics

Community63

Healthy contributor diversity

Maturity93

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 67.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 ~42 days

Recently: every ~107 days

Total

111

Last Release

62d ago

Major Versions

v1.11.3 → v2.0.02015-02-04

v1.11.4 → v2.0.12015-02-23

v1.11.6 → v2.0.32015-03-17

1.11.x-dev → v2.4.22018-02-07

2.15.x-dev → v3.0.02024-03-01

PHP version history (8 changes)v1.0.0-beta1PHP &gt;=5.3.0

v2.0.0PHP &gt;=5.4.0

v2.5.0PHP &gt;=7

v2.6.7PHP &gt;=7.2

v2.9.0PHP ^7.3 || ^8.0

v2.15.0PHP ^8.0

v3.0.0PHP ^8.1

v3.2.0PHP ^8.2

### Community

Maintainers

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

---

Top Contributors

[![barryvdh](https://avatars.githubusercontent.com/u/973269?v=4)](https://github.com/barryvdh "barryvdh (514 commits)")[![mfn](https://avatars.githubusercontent.com/u/87493?v=4)](https://github.com/mfn "mfn (105 commits)")[![pataar](https://avatars.githubusercontent.com/u/3403851?v=4)](https://github.com/pataar "pataar (15 commits)")[![netpok](https://avatars.githubusercontent.com/u/6945600?v=4)](https://github.com/netpok "netpok (10 commits)")[![JeppeKnockaert](https://avatars.githubusercontent.com/u/1913807?v=4)](https://github.com/JeppeKnockaert "JeppeKnockaert (9 commits)")[![erikn69](https://avatars.githubusercontent.com/u/4933954?v=4)](https://github.com/erikn69 "erikn69 (8 commits)")[![KentarouTakeda](https://avatars.githubusercontent.com/u/4785040?v=4)](https://github.com/KentarouTakeda "KentarouTakeda (6 commits)")[![mr-feek](https://avatars.githubusercontent.com/u/5747667?v=4)](https://github.com/mr-feek "mr-feek (6 commits)")[![wimski](https://avatars.githubusercontent.com/u/12373573?v=4)](https://github.com/wimski "wimski (6 commits)")[![ahmed-aliraqi](https://avatars.githubusercontent.com/u/23261109?v=4)](https://github.com/ahmed-aliraqi "ahmed-aliraqi (6 commits)")[![eidng8](https://avatars.githubusercontent.com/u/787265?v=4)](https://github.com/eidng8 "eidng8 (5 commits)")[![leo108](https://avatars.githubusercontent.com/u/1551716?v=4)](https://github.com/leo108 "leo108 (5 commits)")[![pahan35](https://avatars.githubusercontent.com/u/13823215?v=4)](https://github.com/pahan35 "pahan35 (5 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (5 commits)")[![isaackaara](https://avatars.githubusercontent.com/u/255471029?v=4)](https://github.com/isaackaara "isaackaara (4 commits)")[![ellisio](https://avatars.githubusercontent.com/u/127468?v=4)](https://github.com/ellisio "ellisio (4 commits)")[![inxilpro](https://avatars.githubusercontent.com/u/21592?v=4)](https://github.com/inxilpro "inxilpro (4 commits)")[![Gummibeer](https://avatars.githubusercontent.com/u/6187884?v=4)](https://github.com/Gummibeer "Gummibeer (4 commits)")[![zedentox](https://avatars.githubusercontent.com/u/3627991?v=4)](https://github.com/zedentox "zedentox (3 commits)")[![binotaliu](https://avatars.githubusercontent.com/u/67255597?v=4)](https://github.com/binotaliu "binotaliu (3 commits)")

---

Tags

autocompletionhacktoberfestlaravelphpdoclaravelautocompletehelperdevidephpstormnetbeanssublimecodeintel

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Psalm

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/barryvdh-laravel-ide-helper/health.svg)

```
[![Health](https://phpackages.com/badges/barryvdh-laravel-ide-helper/health.svg)](https://phpackages.com/packages/barryvdh-laravel-ide-helper)
```

###  Alternatives

[mis/yii2-ide-helper

Yii2 IDE Helper, generates correct PHPDocs for all components, to improve auto-completion.

1664.2k3](/packages/mis-yii2-ide-helper)[soyhuce/next-ide-helper

Laravel ide helper rebuilt under steroids

4756.2k3](/packages/soyhuce-next-ide-helper)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)[gonetone/laravel-boost-windsurf-extension

Laravel Boost extension package that provides Windsurf editor and Windsurf JetBrains plugin integration.

239.1k](/packages/gonetone-laravel-boost-windsurf-extension)

PHPackages © 2026

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