Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Phpstorm Stubs Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Purpose Alignment: The jetbrains/phpstorm-stubs package provides PHPDoc-annotated stub files for PHP core functions and extensions, directly addressing PhpStorm’s static analysis limitations in Laravel ecosystems. It bridges gaps between IDE autocompletion, type inference, and static analysis tools (e.g., Psalm, PHPStan), which is critical for Laravel’s type-heavy and extension-dependent codebase (e.g., Illuminate\Support, Predis, Symfony Components).
  • Laravel-Specific Synergies:
    • Framework Integration: Improves IDE support for Laravel’s facades, collections, and service containers by providing accurate method signatures (e.g., Facade::call(), Collection::map()).
    • Extension Coverage: Enhances tooling for PECL extensions (e.g., Redis, PDO, Intl) commonly used in Laravel apps, reducing manual stub maintenance.
    • PHP 8.x+ Features: Future-proofs Laravel apps for named arguments, union types, and attributes (e.g., #[\Override]), which PhpStorm’s built-in stubs may lag on.
  • Non-Invasive: Since stubs are static files, they do not modify runtime behavior but enhance developer experience—ideal for a TPM to champion as a DX investment.

Integration Feasibility

  • Zero-Cost Adoption: Installable via Composer (composer require --dev jetbrains/phpstorm-stubs) with no configuration required. PhpStorm auto-detects stubs in vendor/ directory.
  • Laravel Compatibility:
    • No Conflicts: Stubs are additive and do not override Laravel’s built-in stubs (e.g., Illuminate classes).
    • Custom Stubs: If a Laravel package provides its own stubs (e.g., spatie/laravel-activitylog), conflicts can be resolved via PhpStorm’s stub priority rules or .phpstorm.meta.php.
  • IDE Dependency: PhpStorm-specific—no impact on VSCode, CLI tools, or other IDEs. Requires PhpStorm 2021.3+ for full functionality.
  • Build System Impact: Negligible—stubs are ~5MB and ignored in production (via composer.json dev dependency).

Technical Risk

Risk Severity Mitigation
Stub Version Mismatch Medium Pin to a specific major version (e.g., ^1.0) in composer.json.
IDE-Specific Issues Low Test in PhpStorm 2024.2+; fallback to manual stubs if needed.
False Positives in Analysis Low Validate against Psalm/PHPStan baselines to ensure stubs align with static analysis.
Custom Extension Gaps Medium Supplement with community PECL stubs (e.g., ext-redis) or contribute missing stubs upstream.
CI/CD Overhead Low Stubs are dev-only; no impact on build times or deployments.

Key Questions

  1. Is PhpStorm the primary IDE? (If not, ROI is minimal.)
  2. Are there existing custom stubs? (Conflict resolution may be needed.)
  3. Does the team use Psalm/PHPStan? (Stubs amplify static analysis benefits.)
  4. What’s the PHP version? (Stubs for PHP 8.0+ are most comprehensive.)
  5. Who owns IDE tooling maintenance? (JetBrains or internal team?)
  6. Are there unsupported extensions critical to Laravel? (e.g., MongoDB, Propro—may require manual stubs.)

Integration Approach

Stack Fit

  • Primary Fit:
    • PhpStorm + Laravel (PHP 8.0+): Directly enhances autocompletion, refactoring, and type inference.
    • Psalm/PHPStan: Aligns IDE hints with static analysis tools, reducing discrepancies in type checking.
  • Secondary Fit:
    • Monorepos: Centralized stub management across multiple Laravel apps.
    • Custom IDE Plugins: If extending PhpStorm’s analysis (e.g., for internal frameworks).
  • Non-Fit:
    • VSCode/WebStorm: Use phpactor or intelephense instead.
    • CLI-Only Workflows: No impact (stubs are IDE-specific).
    • Legacy PHP (<7.4): Limited stub coverage for modern PHP features.

Migration Path

  1. Assessment Phase:
    • Audit current PhpStorm version and plugins (e.g., PHP Annotations).
    • Check for existing stubs (e.g., in stubs/ or vendor/).
    • Benchmark current IDE performance (e.g., method resolution time).
  2. Pilot Integration:
    • Add stubs to a non-production Laravel app:
      composer require --dev jetbrains/phpstorm-stubs
      
    • Validate in PhpStorm:
      • Test autocompletion for array_* functions (e.g., array_map).
      • Verify type hints for JsonSerializable and IteratorAggregate.
      • Check facade/method chaining (e.g., Auth::user()->posts()).
  3. Full Rollout:
    • Update composer.json across all Laravel repos with a pinned version:
      "require-dev": {
          "jetbrains/phpstorm-stubs": "^1.0"
      }
      
    • Document in CONTRIBUTING.md or IDE_SETUP.md for onboarding.
  4. Fallback Plan:
    • If stubs cause issues (e.g., conflicts with custom stubs), exclude them in PhpStorm:
      • Go to Settings > Languages & Frameworks > PHP > PHP Runtime.
      • Add vendor/jetbrains/phpstorm-stubs to Excluded Paths.

Compatibility

Component Compatibility Notes
Laravel 10/11 Full support (PHP 8.1+ stubs included; covers Illuminate and Symfony components).
PHP 8.0 Partial (some newer functions may lack stubs; test thoroughly).
Custom Extensions Requires manual PECL stubs (e.g., ext-mongodb). JetBrains only validates PHPDoc, not functionality.
Psalm/PHPStan Improves alignment but does not replace their type systems. Use stubs to reduce false positives.
Docker/CI No impact; stubs are dev-only.
Windows/Linux/macOS Cross-platform; no OS-specific issues.

Sequencing

  1. Phase 1: Add Stubs to Dev Environment
    • Install in a local Laravel app and validate IDE behavior.
    • Test with Psalm/PHPStan to ensure no regressions.
  2. Phase 2: Train Team
    • Workshop on leveraging stubs (e.g., @method annotations, @var for dynamic returns).
    • Document common stub use cases (e.g., Collection methods, Facade calls).
  3. Phase 3: Integrate with CI (Optional)
    • Add pre-commit IDE checks (e.g., via php-cs-fixer + stubs) to catch docblock inconsistencies.
  4. Phase 4: Contribute Upstream (Optional)
    • Submit missing Laravel-specific stubs (e.g., for Laravel\Nova, Laravel\Vapor) to the repo.

Operational Impact

Maintenance

  • Low Effort:
    • Automatic Updates: Managed via Composer (pin major version to avoid surprises).
    • No Runtime Maintenance: Stubs are static files; no server restarts or redeploys needed.
    • Community-Backed: JetBrains maintains core stubs; community handles extensions.
  • Moderate Effort:
    • Stub Customization: If using unsupported extensions, maintain local stubs or contribute upstream.
    • Version Pinning: Requires occasional major version updates (e.g., for PHP 8.3 support).
  • High Effort (Rare):
    • Conflict Resolution: If custom stubs exist, may need to merge or exclude JetBrains’ stubs.

Support

  • PhpStorm-Specific: Support is JetBrains’ responsibility for core stubs; community-driven for extensions.
  • Troubleshooting:
    • **Invalidate C
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
emuniq/filament-browser-notifications
syriable/filament-translator
hungnm28/livewire-form
wenprise/eloquent
crudly/encrypted
fadion/bouncy
cuci/prototurk-sdk
gos/pubsub-router-bundle
cuci/prototurk-sdk-symfony
clementtalleu/easyadmin-markdown-bundle
codeflextech/permission-manager
karnoweb/livewire-datepicker
sayedenam/sayed-dashboard
milito/query-filter
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui