barryvdh/laravel-ide-helper
Generates accurate PHPDoc helper files for Laravel to improve IDE autocompletion and type hints. Create _ide_helper.php for facades, add or export model PHPDocs, fluent methods, factory builders, and PhpStorm container metadata—kept in sync with your project.
_ide_helper.php, _ide_helper_models.php) or injecting PHPDocs into existing files, avoiding modifications to core Laravel logic.storage/framework/cache/).config/ide-helper.php (e.g., ignored models, custom relation types, generics annotations). Supports hooks for advanced use cases.--write) risks overwriting manual annotations or breaking existing code. Mitigated by --nowrite or --write-mixin options.composer.json post-update-cmd) can mitigate this.--write), kept separate (--nowrite), or use mixins (--write-mixin) to avoid duplicates?post-update-cmd) or run manually?additional_relation_types in the config need customization?composer require --dev barryvdh/laravel-ide-helper
dev dependencies to avoid production bloat.php artisan vendor:publish --provider="Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider" --tag=config
config/ide-helper.php (e.g., ignored models, relation types, generics annotations).php artisan ide-helper:generate
# Option 1: Write to separate file (recommended for safety)
php artisan ide-helper:models --nowrite
# Option 2: Write directly to models (use with caution)
php artisan ide-helper:models --write
# Option 3: Use mixins (avoids duplicates)
php artisan ide-helper:models --write-mixin
php artisan ide-helper:generate --fluent
composer.json for post-update generation:
"scripts": {
"post-update-cmd": [
"@php artisan ide-helper:generate",
"@php artisan ide-helper:models --nowrite"
]
}
.env or CI flags).-M flag for SQLite in-memory:
php artisan ide-helper:models -M
ide-helper.php.ide-helper:generate after dependency updates or Facade changes.ide-helper:models after schema/migrations or model changes.--reset sparingly (only when PHPDocs are completely outdated).ide-helper.php settings may need updates if:
include_factory_builders is deprecated in Laravel 8+).-M for SQLite if needed.--nowrite or --write-mixin to avoid overwriting manual annotations.--nowrite to avoid file I/O bottlenecks._ide_helper.php) to avoid regenerated on every install.dir options in ide-helper:models to scan specific paths.| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Database connection unavailable | Model PHPDocs fail to generate | Use -M for SQLite in-memory or skip models. |
| Real-time facades not exercised | Missing Facade PHPDocs | Manually trigger the facade before generation. |
| IDE cache not refreshed | Outdated autocompletion | Restart IDE or clear caches. |
| Manual PHPDocs overwritten | Broken model annotations | Use |
How can I help you explore Laravel packages today?