- How do I install phpstorm-stubs in a Laravel project?
- Run `composer require --dev jetbrains/phpstorm-stubs` in your Laravel project. The `--dev` flag ensures it’s excluded from production builds. No additional code changes are needed; just configure PhpStorm to use the stubs via *Settings > PHP > PHP Runtime > Advanced > Default stubs path*.
- Will this package slow down my Laravel application in production?
- No, phpstorm-stubs are purely IDE-focused PHP stub files with zero runtime overhead. They’re installed as a dev dependency and never executed, so they won’t impact performance or memory usage in production.
- Does this support Laravel’s common extensions like Redis or MongoDB?
- Yes, the package includes stubs for core PHP, bundled extensions (e.g., PDO, DOM), and many PECL extensions like Redis and MongoDB. However, non-standard extensions rely on community contributions, so verify coverage for your specific stack via the [PHP extensions list](http://php.net/manual/en/extensions.membership.php).
- How do I handle conflicts between PhpStorm’s type hints and PHPStan/Psalm?
- Use PHPStan’s `--level=5` to cross-validate stub accuracy. Enforce consistency by adding a pre-commit hook to check `@return` annotations in your Laravel codebase. Treat PhpStorm stubs as a productivity tool, not a strict type authority, and rely on static analyzers for validation.
- Can I use this with PHP 7.4 or older Laravel projects?
- No, phpstorm-stubs officially supports PHP 8.0+. If your Laravel project uses PHP <8.0, you’ll need to maintain custom stubs or upgrade to PHP 8.0+ to align with modern Laravel requirements (e.g., attributes, union types).
- How do I update stubs when JetBrains releases new versions?
- Clone the [phpstorm-stubs repo](https://github.com/JetBrains/phpstorm-stubs) into your project (e.g., in `/stubs`). Configure PhpStorm to point to this path in *Settings > PHP > PHP Runtime > Advanced*. Use Git to pull updates directly from the repo, ensuring your IDE stays synced with the latest stubs.
- Are there alternatives to phpstorm-stubs for Laravel?
- For PhpStorm, this is the official JetBrains package. Alternatives like custom `.phpstorm.meta.php` files or third-party stubs (e.g., [phpstan/phpstan-stubs](https://github.com/phpstan/phpstan-stubs)) exist but lack the same level of IDE integration. If using VSCode, consider [Intelephense](https://marketplace.visualstudio.com/items?itemName=bmewburn.vscode-intelephense) with custom stubs.
- How do I add stubs for a custom PECL extension not covered by this package?
- Create a stub file in the same format as the existing ones (e.g., `redis.stub`) and place it in your project’s stubs directory. Validate PHPDoc manually against the extension’s docs or source code. Document the process for your team, as custom stubs require ongoing maintenance.
- Will this package work with Laravel’s pre-commit hooks (e.g., PHP CS Fixer)?
- Yes, you can integrate stub validation into pre-commit hooks. Use tools like `phpstan --level=5` to check `@return` annotations or write a custom script to verify PHPDoc consistency. This ensures stubs align with your Laravel codebase before merging.
- Does this package support Laravel’s new PHP 8.3 features like Fibers or enums?
- The package is actively maintained for PHP 8.0+ and includes support for modern features like enums, attributes, and union types. While Fibers (PHP 8.3) may not be fully covered yet, check the [GitHub repo](https://github.com/JetBrains/phpstorm-stubs) for updates. For cutting-edge features, monitor the project’s release notes.