- What does tutorigo/laravel-ide-macros do?
- It scans your Laravel application for registered macros and generates a helper stub file that IDEs can read. This lets PhpStorm, VS Code with Intelephense, and similar tools autocomplete and type-hint methods added at runtime with Macroable::macro(), which static analysis would otherwise flag as undefined. It is a dev-only supplement to barryvdh/laravel-ide-helper.
- How do I install laravel-ide-macros in a Laravel project?
- Install it as a development dependency with composer require --dev tutorigo/laravel-ide-macros. Then run the package's generation Artisan command to produce the helper file and make sure your IDE indexes it. Because it is require-dev only, it stays out of your production autoload path.
- Does laravel-ide-macros work alongside barryvdh/laravel-ide-helper?
- Yes, it is designed as a supplementary tool that covers macros specifically, while laravel-ide-helper handles models, facades, and container bindings. The two generate separate output files, so you reference both from your IDE configuration. Check that your generation pipeline runs both commands and that neither overwrites the other's file.
- Which Laravel versions does this package support?
- Release 1.6.0 bumps its dependencies for Laravel 9 and is the current compatibility baseline. It fits Laravel 8/9-era applications using Composer and a modern IDE. Always confirm the exact illuminate constraints in composer.json against your app's minimum supported PHP and Laravel versions.
- How do I generate the macro helper file?
- After installing the package, run its generation Artisan command, which scans your codebase for macro registrations and writes the stub file. Re-run it whenever you add or change macros so the IDE stays in sync. If the package exposes a config file, publish it only when you need to change the default output location.
- Does it support Request, TestResponse and TestView macros?
- Yes, version 1.6.0 added coverage for Illuminate\Http\Request macros plus TestResponse and TestView macros used in tests. That means request-shape normalisation macros and custom test assertion helpers now get autocompletion instead of appearing as undefined methods. This is an additive change with no new configuration required.
- Should I commit the generated macro helper file to version control?
- Either approach works, but be deliberate. Committing it gives every developer identical IDE results and keeps diffs visible in code review, while gitignoring it and regenerating per developer guarantees freshness but can cause drift. Many teams gitignore generated IDE files and run generation as part of local setup or a Composer script.
- Will laravel-ide-macros affect my production application?
- No, it ships no runtime service provider logic that affects request handling and should be installed with require-dev. Its only output is a generated stub file consumed by your IDE or static analyser. The worst-case failure is inaccurate autocompletion in development, not a production bug.
- Can PHPStan or Psalm use the generated macro stubs?
- Yes, the generated file is a static stub describing macro methods, so static analysers that load it can resolve calls that would otherwise be reported as undefined. Whether that happens depends on your analyser config including the stub path. Teams that only want IDE convenience can skip wiring it into CI entirely.
- What happens if my macros are registered conditionally?
- The generator only sees macros it can discover in your code, so closures in config, environment guards, or service-provider ordering can cause the stub to silently diverge from what exists at runtime. The result is stale autocompletion or false positives and negatives in the IDE. Keep macro registration in a single discoverable location, or regenerate and review the output after changing conditional logic.