Need help with laravel-ide-helper?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

11.7K Stars 1.0K Forks MIT License 802 Commits 106 Opened issues


Laravel IDE Helper

Services available


Need anything else?

Contributors list

Laravel IDE Helper Generator

Latest Version on Packagist Software License Build Status Total Downloads

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.


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, 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

key in
, e.g.
  "extra": {
    "laravel": {
      "dont-discover": [
- Add the following class to the
array in
If you want to manually load it only in non-production environments, instead you can add this to your
with the
  public function register()
      if ($this->app->isLocal()) {
      // ...

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


Check out this Laracasts video for a quick introduction/explanation!

Note: You do need CodeComplice for Sublime Text:

Automatic PHPDoc generation for Laravel Facades

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

php artisan ide-helper:generate


has to be cleared first, so run
php artisan clear-compiled
before generating.

This will generate the file

which is expected to be additionally parsed by your IDE for autocomplete. You can use the config
to change its name.

You can configure your

to do this each time you update your dependencies:
"scripts": {
    "post-update-cmd": [
        "@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

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


You can choose to include helper files. This is not enabled by default, but you can override it with the

--helpers (-H)
option. The
is already set up, but you can add/remove your own files in the config file.

Automatic PHPDoc generation for macros and mixins

This package can generate PHPDocs for macros and mixins which will be added to the


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

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 (

). 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 (
). 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)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Post forAuthors(\User ...$authors)
 * …

With the

--write-mixin (-M)
 * …
 * @mixin IdeHelperPost

Model Directories

By default, models in

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

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

Models can be ignored using the

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

Or can be ignored by setting the

'ignored_models' => [


Eloquent allows calling

on your models, e.g.
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

and setting it to


You may use the

method to count the number results from a relationship without actually loading them. Those results are then placed in attributes following the


By default, these attributes are generated in the phpdoc. You can turn them off by setting the config


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

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

// => after generate models

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

Dedicated Eloquent Builder methods

A new method to the eloquent models was added called

Reference 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

and setting it to

Unsupported or custom database types

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


But sometimes you may want to use custom column types in your database like

, etc. which may throw an "Unknown database type"-Exception.

For those special cases, you can map them via the config

. Example:
'custom_db_types' => [
    'mysql' => [
        'geography' => 'array',
        'point' => 'array',
    'postgresql' => [
        'jsonb' => 'string',
        '_int4' => 'array',

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

and add it to the
array in the config:
'model_hooks' => [


method will be called during generation for every model and receives the current running
and the current
, e.g.:
class MyCustomHook implements ModelHookInterface
    public function run(ModelsCommand $command, Model $model): void
        if (! $model instanceof MyModel) {

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



  • MyModel
  • @property integer $id
  • @property-read string $custom

Automatic PHPDocs generation for Laravel Fluent methods

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


After publishing vendor, simply change the

line your
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

If you would like the

methods to return the correct model class, you can enable custom factory builders with the
line your
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

It's possible to generate a PhpStorm meta file to add support for factory design pattern. For Laravel, this means we can make PhpStorm understand what kind of object we are resolving from the IoC Container. For example,

will return an
object, so with the meta file you can call
and it will autocomplete the Dispatcher methods.
php artisan ide-helper:meta

/** @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

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

. This can be useful for cases you want to take advantage the PhpStorm also supports the directory
which would parse any file places there, should your want provide additional files to PhpStorm.

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

, some alterations must be made.

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

function to add additional Facades into your application.

Adding the Service Provider

You can install Laravel IDE Helper in

, 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
if ($app->environment() !== 'production') {

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

Currently, Lumen IDE Helper doesn't take into account additional Facades created under

, so you need to create a
file and add your custom aliases under an
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
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.


The Laravel IDE Helper Generator is open-sourced software licensed under the MIT license

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.