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

Phpstan Config Laravel Package

eliashaeussler/phpstan-config

Opinionated PHPStan configuration presets and extensions by Elias Häußler. Drop-in rules and baseline settings to standardize static analysis across projects, reduce false positives, and improve code quality with minimal setup for common PHP/Laravel workflows.

View on GitHub
Deep Wiki
Context7

Getting Started

  1. Install the package into your project via Composer:
    composer require --dev eliashaeussler/phpstan-config
    
  2. In your project’s phpstan.neon root config file, extend the provided baseline config:
    includes:
        - vendor/eliashaeussler/phpstan-config/phpstan.neon
    
  3. Run PHPStan for the first time:
    vendor/bin/phpstan analyse src
    
    Expect some baseline violations if your codebase isn’t conforming to the shared rules—generate a baseline to suppress known issues:
    vendor/bin/phpstan analyse src --generate-baseline
    

Implementation Patterns

  • Team-wide consistency: Include eliashaeussler/phpstan-config in all new projects and existing repos to enforce uniform error levels and rule sets.
  • Per-project overrides: Add project-specific rules in phpstan.neon after the includes block (order matters—later config overrides earlier):
    includes:
        - vendor/eliashaeussler/phpstan-config/phpstan.neon
    
    parameters:
        errorLevel: 6  #收紧到团队标准
        # …project-specific rules or skipPatterns…
    
  • CI integration: In your CI pipeline (github/workflows, GitLab CI, etc.), run PHPStan with the shared config—no need to copy configs across repos.
  • Gradual adoption: Start with the default (typically level 4–5), increase errorLevel incrementally per sprint while generating new baselines.
  • PHP version pinning: Configure the required PHP version in your project’s composer.json to align with PHPStan’s runtime and rules (e.g., php: "^8.1").

Gotchas and Tips

  • Config order matters: Everything after includes overrides defaults. Avoid duplicating includes or misordering parameters.
  • Baseline drift: Regenerate baselines regularly—especially before upgrading PHP or changing PHPStan levels. Outdated baselines hide regressions.
  • IDE compatibility: Ensure your IDE (e.g., PHPStan extension for VS Code or PhpStorm) uses the project’s Composer autoloader to pick up the extended config correctly.
  • No built-in ruleset presets: The package provides one phpstan.neon, not multiple profiles (e.g., laravel, symfony). Extend via includes[] or parameters for team flavors.
  • Lock versions carefully: Pin the version in composer.json to avoid unintentional rule changes on phpstan-config updates—treat it like a framework dependency.
  • Debugging issues: Run with -c to confirm which config is used and --debug to see which rules fired. Check vendor/eliashaeussler/phpstan-config for the actual config file contents if behavior seems unexpected.
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.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport