jetbrains/phpstorm-stubs
PhpStorm Stubs: syntactically correct PHP files with signatures, constants, and PHPDoc for PHP core and many extensions. Used by IDEs for completion, inspections, type inference, and documentation popups. Community-driven support for non-standard extensions.
Illuminate\Support\Collection methods). Reduces context-switching between IDE and CLI tools like php artisan tinker.@return \Illuminate\Support\Collection<int, string>). Bridges gaps between PhpStorm’s static analysis and Psalm/PHPStan.PDO, Redis, DOM). Saves ~50+ hours/year per team by eliminating manual .phpstorm.meta.php files or third-party stub generators.->where()?").array_unpack, Fibers, enums) before PhpStorm’s built-in stubs are updated.php-cs-fixer + stubs) to catch docblock inconsistencies (e.g., @return array vs. @return array<int, mixed>) before merge.Adopt if:
Eloquent, Collections, Facades) and need full IDE support.array vs. array<int, string>)..phpstorm.meta.php files.Look elsewhere if:
phpactor or intelephense).php artisan or php -r).spatie/laravel-activitylog with custom PECL bindings)."This is the ‘GitHub Copilot for PHP tooling’—a free, JetBrains-backed solution that turns PhpStorm into a Laravel powerhouse. Here’s why it’s a no-brainer:
- Saves 100+ hours/year by eliminating manual stub maintenance (no more
.phpstorm.meta.phphell).- Reduces bugs from IDE misconfigurations (e.g., wrong return types in
Collection::map()).- Future-proofs Laravel for PHP 8.3+ without waiting for PhpStorm updates.
- Zero cost: Apache-2.0 licensed, used by Laravel’s own tooling.
- Aligns with PSR-12/Psalm: Ensures IDE and static analysis tools agree on types.
Cost? Free. ROI? Faster onboarding, fewer IDE-related bugs, and happier devs—all while future-proofing our stack."
"Tired of PhpStorm guessing types or missing Laravel method signatures? These stubs fix that:
- Autocompletion: No more
->where()→ "Could not resolve method".- Refactoring: Safe renames/extractions for
Eloquentqueries.- PSR-12 Compliance: IDE-enforced
@returnannotations match Psalm/PHPStan.- Laravel-Specific: Better support for
Collection,Facade, andServiceProviderstubs.How to enable?
- Run:
composer require --dev jetbrains/phpstorm-stubs- Restart PhpStorm (
File > Invalidate Caches).- Profit: Instantly better DX.
Downside? None—it’s maintained by JetBrains and backward-compatible with Laravel 10/11."
"This addresses a hidden technical debt in PHP tooling:
- Tooling fragmentation: IDEs and static analyzers often disagree on types (e.g.,
arrayvs.array<string>).- Vendor lock-in risk: PhpStorm’s built-in stubs are incomplete for extensions (e.g.,
Redis,PDO).- Scalability: As our codebase grows, manual stubs become unsustainable.
By adopting this, we:
- Standardize on JetBrains’ official stubs (used by Laravel, Symfony, etc.).
- Align IDE and CLI tooling (Psalm/PHPStan will now match PhpStorm’s hints).
- Reduce context-switching for devs moving between local IDEs and CI/CD.
Recommendation: Pilot with 1–2 teams (e.g., Laravel core or high-extension-use repos) and measure bug reduction and onboarding time.*"
"This is a dev-only package with zero runtime impact, but it supercharges CI/CD by:
- Enabling pre-commit IDE checks (e.g., via
php-cs-fixer+ stubs) to catch docblock inconsistencies.- Reducing flaky tests caused by IDE misconfigurations (e.g., wrong type hints in
array_map).- No CI overhead: Stubs are ~5MB and only used in dev environments.
No changes needed to pipelines—just add it to
composer.jsonand let devs benefit."
How can I help you explore Laravel packages today?