PHPStan Installation and Setup

Installation Steps

  1. Install PHPStan and Larastan via Composer:
    composer require --dev phpstan/phpstan larastan/larastan

Configuration Steps

  1. Create phpstan.neon file in project root:
    • Location: phpstan.neon or phpstan.dist.neon (root directory)
    includes:
        - ./vendor/larastan/larastan/extension.neon
    
    parameters:
        level: 5
        paths:
            - app
  2. Run PHPStan analysis:
    ./vendor/bin/phpstan analyse
  3. Add to composer.json scripts section:
    • Location: composer.json (scripts section)
    "scripts": {
        "analyse": "./vendor/bin/phpstan analyse"
    }
  4. Verify configuration is committed to version control
    • Check: phpstan.neon should be in repository

Did you find this article useful?

  • Laravel SOP

    Introduction & Overview Laravel Version Compatibility Project uses Laravel 12.x or later (lates...
  • Laravel Pint Installation and Setup

    Installation Steps Install Laravel Pint (included by default in Laravel 12+, or install via Compose...