Skip to content

Guide · Open source

How to use laravel-ide-helper: install, generate and tips

Updated · written with AI from the project's own documentation and checked against our catalogue data

laravel-ide-helper is a Composer package for Laravel projects. It reads your project's files and generates helper files so your editor can offer more accurate autocompletion and type hints for Laravel facades and Eloquent models. This guide covers installation, the main Artisan commands, and the options that decide where the generated docs end up.

IDE Helperbarryvdh/laravel-ide-helper · ★ 15k · MIT

Quick start

  1. 1Check your setup. Confirm you have PHP, Composer and Laravel 10 or later, and that your database connection works.
  2. 2Install the package. Run the Composer require command with the --dev flag to add laravel-ide-helper as a dev dependency.
  3. 3Generate facade helpers. Run php artisan ide-helper:generate to create _ide_helper.php for your editor to parse.
  4. 4Generate model PHPDocs. Run php artisan ide-helper:models and choose whether to write into model files or a separate file.
  5. 5Regenerate after changes. Run the commands again when your project changes so the helpers stay current.

Check requirements before you install

The README says the 3.x branch supports Laravel 10 and later. For older versions, use the 2.x releases instead.

Model generation requires a working database connection, because the command introspects the table of each model. Some facades may also be skipped if there is no default working connection.

  • PHP and Composer
  • Laravel 10 or later for the 3.x branch
  • A working database connection for model generation

Install laravel-ide-helper as a dev dependency

Require the package with Composer using the command below. It is installed as a development dependency.

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

Generate autocompletion for facades

Run the generate command to create the facade helper file. It creates _ide_helper.php. Your IDE is expected to parse this file for autocomplete.

You can change the file name with the filename config. To regenerate the docs after updates, run the command again. The README also shows adding it to the post-update-cmd script in composer.json so it runs each time you update dependencies. If you do not want the full file, you can use the -M option to use an in-memory SQLite driver when a database connection is missing.

  • Use --helpers (-H) to include helper files, which is not enabled by default
  • Publish the config file to change implementations or set defaults for --helpers
php artisan ide-helper:generate

Generate PHPDocs for Eloquent models

The models command generates PHPDocs based on table columns, relations and getters/setters. By default you are asked whether to overwrite or write to a separate file, _ide_helper_models.php.

Use --write (-W) to write comments directly into your model files, or --nowrite (-N) to avoid writing. The README says to back up your models before writing. The --reset (-R) option replaces the whole existing PHPDoc, including any comments you made. Without it, writing keeps existing comments and only appends new properties and methods.

  • Use --write-mixin (-M) to add only a @mixin tag to the model and keep the generated docs in a separate file
  • Use --write-eloquent-helper (-E) to generate a smaller helper file needed for QueryBuilder methods
  • Use --ignore (-I) or the ignored_models config to skip models
php artisan ide-helper:models -RW

Target specific models and directories

Pass model class names to scan only those models. By default, models in app/models are scanned. Use --dir to scan another directory, relative to the base path.

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

Know the editor-specific notes

The README says Sublime Text users need CodeComplice for autocompletion. It also mentions PhpStorm Meta files, which are generated with the ide-helper:meta command, for container instances.

Real-time facades are included through a @mixin annotation, but only if the framework has already generated their files in storage/framework/cache. Run the route, command or code first, then regenerate the helper file.

php artisan ide-helper:meta

What people use it for

  • Getting autocompletion for Laravel facades in PhpStorm or VS Code
  • Adding generated property and method PHPDocs to Eloquent models
  • Generating a PhpStorm meta file for container instances with ide-helper:meta
  • Keeping generated docs in a separate file so they are not marked as duplicates

Frequently asked questions

Is laravel-ide-helper free to use?

Yes. The package is licensed under the MIT licence, as stated in the project's details. Check the repository's licence file for the full terms.

Which Laravel version does laravel-ide-helper support?

The README says the 3.x branch supports Laravel 10 and later. For older Laravel versions, the README says to use the 2.x releases.

How do I install laravel-ide-helper?

Run composer require --dev barryvdh/laravel-ide-helper in your Laravel project. The --dev flag installs it as a development dependency.

Why are some facades missing from the generated file?

The README says some classes need a working database connection. If there is no default working connection, some facades will not be included. You can use the -M option to use an in-memory SQLite driver.

Does laravel-ide-helper work with Sublime Text?

The README says you need CodeComplice for Sublime Text. Without that extra tooling, autocompletion is not provided by this package alone.

Will model PHPDocs overwrite my comments?

Not by default. Writing keeps existing comments and only appends new properties and methods. The --reset (-R) option replaces the whole existing PHPDoc, including your comments.

New agent skills, repos and AI tools — every week

The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.

Our verdict

Use laravel-ide-helper if you are a Laravel developer on version 10 or later who works in an IDE such as PhpStorm or VS Code and wants better autocompletion for facades and models. Pick something else if your project runs an older Laravel version, since the README points those to the 2.x releases, or if you cannot provide a working database connection for model generation.

Install options & downloads

Find exactly what
you're looking for