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

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

lozhkindm/laravel-ide-helper
============================

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

v2.11.0(4y ago)06MITPHPPHP ^7.3 || ^8.0

Since May 23Pushed 4y agoCompare

[ Source](https://github.com/lozhkindm/laravel-ide-helper)[ Packagist](https://packagist.org/packages/lozhkindm/laravel-ide-helper)[ GitHub Sponsors](https://github.com/barryvdh)[ RSS](/packages/lozhkindm-laravel-ide-helper/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (16)Versions (88)Used By (0)

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

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

[![Latest Version on Packagist](https://camo.githubusercontent.com/a801c9fdf0a71f0fc95b2b7d38298264f6b8f51fe1b99526b8778c9a8f5dbfb0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f62617272797664682f6c61726176656c2d6964652d68656c7065722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/barryvdh/laravel-ide-helper)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://github.com/barryvdh/laravel-ide-helper/workflows/Tests/badge.svg)](https://github.com/barryvdh/laravel-ide-helper/actions)[![Total Downloads](https://camo.githubusercontent.com/805ee28f68c4d58860775098a16ccea9c7a41887d2565b986573092c81219cb6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f62617272797664682f6c61726176656c2d6964652d68656c7065722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/barryvdh/laravel-ide-helper)

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

- [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)
- [Usage with Lumen](#usage-with-lumen)
    - [Enabling Facades](#enabling-facades)
    - [Adding the Service Provider](#adding-the-service-provider)
    - [Adding Additional Facades](#adding-additional-facades)
- [License](#license)

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

[](#installation)

Require this package with composer using the following command:

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

This package makes use of [Laravels package auto-discovery mechanism](https://medium.com/@taylorotwell/package-auto-discovery-in-laravel-5-5-ea9e3ab20518), which means if you don't install dev dependencies in production, it also won't be loaded.

If for some reason you want manually control this:

- add the package to the `extra.laravel.dont-discover` key in `composer.json`, e.g. ```
    "extra": {
      "laravel": {
        "dont-discover": [
          "barryvdh/laravel-ide-helper"
        ]
      }
    }
    ```
- Add the following class to the `providers` array in `config/app.php`: ```
    Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class,
    ```

    If you want to manually load it only in non-production environments, instead you can add this to your `AppServiceProvider` with the `register()` method: ```
    public function register()
    {
        if ($this->app->isLocal()) {
            $this->app->register(\Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class);
        }
        // ...
    }
    ```

> Note: Avoid caching the configuration in your development environment, it may cause issues after installing this package; respectively clear the cache beforehand via `php artisan cache:clear` if you encounter problems when running the commands

Usage
-----

[](#usage)

*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
```

Note: `bootstrap/compiled.php` has to be cleared first, so run `php artisan clear-compiled` before generating.

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.

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.

Writing to the models should keep the existing comments and only append new properties/methods. The existing PHPDoc is replaced, or added if not found. With the `--reset (-R)` option, the existing PHPDocs are ignored, and only the newly found columns/relations are saved as PHPDocs.

```
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)
 * …
 */
```

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` properties

[](#magic-_count-properties)

You may use the [`::withCount`](https://laravel.com/docs/master/eloquent-relationships#counting-related-models) method to count the number results from a relationship without actually loading them. Those results are then placed in attributes following the `_count` convention.

By default, these attributes are generated in the phpdoc. You can turn them off by setting the config `write_model_relation_count_properties` 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`.

#### Unsupported or custom database types

[](#unsupported-or-custom-database-types)

Common column types (e.g. varchar, integer) are correctly mapped to PHP types (`string`, `int`).

But sometimes you may want to use custom column types in your database like `geography`, `jsonb`, `citext`, `bit`, etc. which may throw an "Unknown database type"-Exception.

For those special cases, you can map them via the config `custom_db_types`. Example:

```
'custom_db_types' => [
    'mysql' => [
        'geography' => 'array',
        'point' => 'array',
    ],
    'postgresql' => [
        'jsonb' => 'string',
        '_int4' => 'array',
    ],
],
```

#### 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 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 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 you want to take advantage the PhpStorm also supports the *directory* `.phpstorm.meta.php/` which would parse any file places there, should your want provide additional files to PhpStorm.

Usage with Lumen
----------------

[](#usage-with-lumen)

This package is focused on Laravel development, but it can also be used in Lumen with some workarounds. Because Lumen works a little different, as it is like a bare bone version of Laravel and the main configuration parameters are instead located in `bootstrap/app.php`, some alterations must be made.

### Enabling Facades

[](#enabling-facades)

While Laravel IDE Helper can generate automatically default Facades for code hinting, Lumen doesn't come with Facades activated. If you plan in using them, you must enable them under the `Create The Application` section, uncommenting this line:

```
// $app->withFacades();
```

From there, you should be able to use the `create_alias()` function to add additional Facades into your application.

### Adding the Service Provider

[](#adding-the-service-provider)

You can install Laravel IDE Helper in `app/Providers/AppServiceProvider.php`, and uncommenting this line that registers the App Service Providers, so it can properly load.

```
// $app->register(App\Providers\AppServiceProvider::class);
```

If you are not using that line, that is usually handy to manage gracefully multiple Laravel/Lumen installations, you will have to add this line of code under the `Register Service Providers` section of your `bootstrap/app.php`.

```
if ($app->environment() !== 'production') {
    $app->register(\Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class);
}
```

After that, Laravel IDE Helper should work correctly. During the generation process, the script may throw exceptions saying that some Class(s) doesn't exist or there are some undefined indexes. This is normal, as Lumen has some default packages stripped away, like Cookies, Storage and Session. If you plan to add these packages, you will have to add them manually and create additional Facades if needed.

### Adding Additional Facades

[](#adding-additional-facades)

Currently, Lumen IDE Helper doesn't take into account additional Facades created under `bootstrap/app.php` using `create_alias()`, so you need to create a `config/app.php` file and add your custom aliases under an `aliases` array again, like so:

```
return [
    'aliases' => [
        'CustomAliasOne' => Example\Support\Facades\CustomAliasOne::class,
        'CustomAliasTwo' => Example\Support\Facades\CustomAliasTwo::class,
        //...
    ]
];
```

After you run `php artisan ide-helper:generate`, it's recommended (but not mandatory) to rename `config/app.php` to something else, until you have to re-generate the docs or after passing to production environment. Lumen 5.1+ will read this file for configuration parameters if it is present, and may overlap some configurations if it is completely populated.

License
-------

[](#license)

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

###  Health Score

34

—

LowBetter than 79% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity84

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 71.1% 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 ~34 days

Recently: every ~8 days

Total

85

Last Release

1798d ago

Major Versions

v1.11.3 → v2.0.02015-02-04

v1.9.3 → v2.0.12015-02-23

v1.11.6 → v2.0.32015-03-17

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

PHP version history (5 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

### Community

Maintainers

![](https://www.gravatar.com/avatar/9f03aecad045eadf169c14e7820e9d187a62dd0f4dffa5ebddd6874ee054010e?d=identicon)[lozhkindm](/maintainers/lozhkindm)

---

Top Contributors

[![barryvdh](https://avatars.githubusercontent.com/u/973269?v=4)](https://github.com/barryvdh "barryvdh (429 commits)")[![mfn](https://avatars.githubusercontent.com/u/87493?v=4)](https://github.com/mfn "mfn (75 commits)")[![netpok](https://avatars.githubusercontent.com/u/6945600?v=4)](https://github.com/netpok "netpok (9 commits)")[![JeppeKnockaert](https://avatars.githubusercontent.com/u/1913807?v=4)](https://github.com/JeppeKnockaert "JeppeKnockaert (8 commits)")[![ahmed-aliraqi](https://avatars.githubusercontent.com/u/23261109?v=4)](https://github.com/ahmed-aliraqi "ahmed-aliraqi (6 commits)")[![mr-feek](https://avatars.githubusercontent.com/u/5747667?v=4)](https://github.com/mr-feek "mr-feek (6 commits)")[![pahan35](https://avatars.githubusercontent.com/u/13823215?v=4)](https://github.com/pahan35 "pahan35 (5 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)")[![eidng8](https://avatars.githubusercontent.com/u/787265?v=4)](https://github.com/eidng8 "eidng8 (4 commits)")[![ellisio](https://avatars.githubusercontent.com/u/127468?v=4)](https://github.com/ellisio "ellisio (4 commits)")[![leo108](https://avatars.githubusercontent.com/u/1551716?v=4)](https://github.com/leo108 "leo108 (4 commits)")[![zedentox](https://avatars.githubusercontent.com/u/3627991?v=4)](https://github.com/zedentox "zedentox (3 commits)")[![brendt](https://avatars.githubusercontent.com/u/6905297?v=4)](https://github.com/brendt "brendt (3 commits)")[![claar](https://avatars.githubusercontent.com/u/402855?v=4)](https://github.com/claar "claar (3 commits)")[![hailwood](https://avatars.githubusercontent.com/u/709773?v=4)](https://github.com/hailwood "hailwood (3 commits)")[![iPaat](https://avatars.githubusercontent.com/u/943484?v=4)](https://github.com/iPaat "iPaat (3 commits)")[![KaloyanYosifov](https://avatars.githubusercontent.com/u/32775332?v=4)](https://github.com/KaloyanYosifov "KaloyanYosifov (3 commits)")[![loilo](https://avatars.githubusercontent.com/u/1922624?v=4)](https://github.com/loilo "loilo (3 commits)")[![mgrinspan](https://avatars.githubusercontent.com/u/8433459?v=4)](https://github.com/mgrinspan "mgrinspan (3 commits)")

---

Tags

phpdoclaravelautocompletehelperidephpstormnetbeanssublimecodeintel

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[barryvdh/laravel-ide-helper

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

14.9k120.0M583](/packages/barryvdh-laravel-ide-helper)[mis/yii2-ide-helper

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

1463.7k3](/packages/mis-yii2-ide-helper)[phalcon/ide-stubs

The most complete Phalcon Framework IDE stubs library which enables autocompletion in modern IDEs.

1623.0M118](/packages/phalcon-ide-stubs)

PHPackages © 2026

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