- How do I install phpstorm-stubs for Laravel projects?
- Add it as a dev dependency via Composer: `composer require --dev jetbrains/phpstorm-stubs`. Then configure PhpStorm to use the stubs by navigating to *Settings > Languages & Frameworks > PHP > PHP Runtime > Advanced* and setting the *Default stubs path* to `vendor/jetbrains/phpstorm-stubs`. Restart the IDE for changes to take effect.
- Which Laravel versions and PHP versions are supported?
- The package works with Laravel 10/11 and PHP 8.1+. For older PHP versions (e.g., 7.4), use an older stub version like `^2021.3`. Always align the stub version with your PHP runtime to avoid inconsistencies in IDE behavior.
- Will this package slow down my Laravel application in production?
- No, stubs are purely for static analysis and IDE tooling. They are ignored by PHP’s runtime parser, so there’s zero performance impact on production. The package is designed as a dev-only dependency.
- How do I use these stubs with PHPStan or Psalm in Laravel?
- Configure PHPStan or Psalm to include the stubs by adding this to your config: `stubFiles: [vendor/jetbrains/phpstorm-stubs]`. This enables type inference and static analysis across your Laravel codebase, including Blade templates and custom helpers.
- What if my Laravel app uses non-standard extensions like Redis or Swoole?
- Community-driven stubs exist for many non-standard extensions (e.g., Redis, Swoole), but they’re not officially validated. Check the [supported extensions list](http://php.net/manual/en/extensions.membership.php) and contribute missing stubs via GitHub if needed. For critical extensions, manually add stubs to `stubs/ext-*.stub.php`.
- How do I update stubs to match a new PHP version in Laravel?
- Clone the `jetbrains/phpstorm-stubs` repo locally, then point PhpStorm to the local path in *Settings > Languages & Frameworks > PHP > PHP Runtime > Advanced*. Use Git to pull updates, ensuring your stubs stay aligned with PHP’s latest API changes.
- Can I use this with VS Code or other IDEs besides PhpStorm?
- Yes, while optimized for PhpStorm, the stubs work with VS Code (via Intelephense) and other IDEs supporting PHP stub files. Configure your IDE’s PHP runtime settings to point to `vendor/jetbrains/phpstorm-stubs` for consistent behavior.
- What’s the difference between this and manually writing PHPDoc in Laravel?
- Manual PHPDoc is error-prone and time-consuming, especially for PHP core functions. This package provides **comprehensive, validated stubs** for thousands of functions, classes, and constants, ensuring accurate autocomplete, type inference, and static analysis without manual effort.
- How do I contribute missing stubs for Laravel-specific packages (e.g., spatie/laravel-permission)?
- Follow the [contribution guide](https://github.com/JetBrains/phpstorm-stubs/blob/master/CONTRIBUTING.md). Fork the repo, add stubs for missing extensions or packages, and submit a pull request. For Laravel-specific packages, ensure stubs align with the package’s PHPDoc standards.
- Should I include this in CI for Laravel projects?
- Yes, integrate it into CI for static analysis (e.g., PHPStan/Psalm) to catch type errors early. Add a step to validate stubs against your PHP version and fail builds if inconsistencies are detected. This ensures IDE accuracy across your team.