- How do I install laravel-ide-helper for Laravel 10+?
- Run `composer require --dev barryvdh/laravel-ide-helper` to install the package. The 3.x branch is explicitly designed for Laravel 10+ and supports modern features like generics annotations. No additional configuration is required for basic usage.
- Will this package slow down my production environment?
- No, the package is installed as a dev dependency and generates static PHPDoc helper files (`_ide_helper.php`). These files are read-only at runtime and have zero impact on performance. Only IDEs use them for autocompletion.
- Can I use this with VS Code instead of PhpStorm?
- Yes, while optimized for PhpStorm, the generated PHPDocs are standard-compliant and work with VS Code (with extensions like IntelliSense or CodeComplice). The autocompletion for Facades, Eloquent, and Fluent methods will function identically.
- How do I generate PHPDocs for Eloquent models without modifying their files?
- Use the `--nowrite` flag with `php artisan ide-helper:models`. This creates a separate `_ide_helper_models.php` file instead of editing your model files directly. Example: `php artisan ide-helper:models --nowrite`.
- Does this support custom Eloquent relationships or complex facades?
- Yes, the package supports custom relationships via model hooks and config overrides. For complex facades, use the `--reset` flag to regenerate PHPDocs after adding new methods. Consult the [customization docs](https://github.com/barryvdh/laravel-ide-helper#model-hooks) for advanced use cases.
- How can I integrate this into my CI/CD pipeline?
- Add the generation commands to your `composer.json` scripts under `post-update-cmd` for automatic execution. For CI environments, use the `-M` flag to specify SQLite or mock the database connection if needed. Example: `php artisan ide-helper:models -M sqlite`.
- What’s the difference between `--write` and `--write-mixin`?
- `--write` directly embeds PHPDocs into your model files, while `--write-mixin` generates a separate `_ide_helper_models.php` file with `@mixin` annotations. Use `--write-mixin` to avoid cluttering model files and improve IDE performance for large projects.
- Can I exclude specific models or directories from PHPDoc generation?
- Yes, use the `--ignore` flag to exclude models or directories. For example, `php artisan ide-helper:models --ignore=App/Models/Archived*`. This is useful for ignoring legacy or third-party models.
- How do I handle conflicts if I manually edited PHPDocs in my models?
- Use `--reset` to overwrite existing PHPDocs with auto-generated ones. For partial conflicts, manually edit the generated `_ide_helper_models.php` file (if using `--nowrite`) or use `--write-mixin` to separate concerns.
- Are there alternatives to this package for Laravel IDE autocompletion?
- Alternatives include `nWidart/laravel-models` (model-specific) or `barryvdh/laravel-debugbar` (for debugging). However, `laravel-ide-helper` is the most comprehensive solution, covering Facades, Eloquent, Fluent methods, and container bindings in a single package. For minimal setups, consider `drefi/laravel-ide-helper` (a fork with additional features).