- How do I integrate this coding standard into an existing Laravel project?
- Run `composer require --dev e-lodgy/coding-standard`, then import the config in your `ecs.php` file using `$config->import('vendor/e-lodgy/coding-standard/ecs.php')`. Specify your Laravel paths (e.g., `src`, `tests`) in the same file. For PHPStan, ensure it’s installed (`composer require --dev phpstan/phpstan`) and configure it separately via `phpstan.neon`.
- Does this package support Laravel’s dynamic facades (e.g., `Log::error()`) without false positives?
- No—PHPStan’s strict rules may flag Laravel facades or dynamic properties as errors. You’ll need to override these in `phpstan.neon` (e.g., `@phpstan-ignore-next-line`) or exclude specific files. Test thoroughly before enforcing in CI. E-Lodgy’s config doesn’t include Laravel-specific exceptions by default.
- What Laravel versions does this coding standard officially support?
- The package is framework-agnostic but works with Laravel 8+ due to PHPStan’s PHP 8.0+ requirements. For older Laravel versions (e.g., 7.x), use PHP_CodeSniffer only (skip PHPStan) or downgrade PHPStan to a compatible version. Test against your Laravel codebase first.
- Can I use this with Laravel Pint for auto-fixing code style issues?
- Yes! While this package focuses on PHP_CodeSniffer and PHPStan, you can pair it with `laravel/pint` for auto-fixing ECS violations. Configure Pint to match E-Lodgy’s rules (e.g., trailing commas, PSR-12) and run it pre-commit. Pint won’t replace PHPStan’s static analysis but complements it.
- How do I configure PHPStan to avoid breaking Laravel’s magic methods (e.g., `__get`, `__call`)?
- Add exceptions to `phpstan.neon` under `[parameters]`. For example, disable `disallowDynamicProperties` for facade classes or use `@phpstan-ignore-line` annotations. E-Lodgy’s config doesn’t block these by default, but strict level 5 may trigger warnings. Start with level 3–4 to balance safety and false positives.
- Will this package slow down my Laravel CI/CD pipeline significantly?
- PHP_CodeSniffer is lightweight, but PHPStan adds runtime overhead (~1–3 minutes for medium Laravel apps). Mitigate this by running PHPStan in parallel with tests (GitHub Actions/GitLab CI) or caching results. Start with warnings-only in CI to gauge impact before enforcing as errors.
- Are there alternatives to this package for Laravel-specific coding standards?
- Yes. For Laravel-focused standards, consider `dealerdirect/phpcodesniffer-composer-installer` (PSR-12) or `nunomaduro/larastan` (PHPStan rules tailored for Laravel). This package is more generic but now includes PHPStan, which is useful for type safety. Evaluate whether you need Laravel-specific overrides.
- How do I customize the PHPStan rules to work with Laravel’s service container?
- Extend `phpstan.neon` with Laravel-specific rules using `phpstan/extension-installer` (e.g., `phpstan/laravel`). Disable container-related checks (e.g., `disallowStaticProperty` for bound services) and document exceptions. Example: `@phpstan-ignore-next-line` for dynamic container calls in `AppServiceProvider`.
- Does this package include any Laravel-specific linting rules (e.g., for Blade templates or migrations)?
- No. This package focuses on PHP files (src/tests/config) and uses PSR-12 + PHPStan. For Blade templates, use `nunomaduro/blade-sniffer` separately. Migrations should follow PSR-12 manually or via Pint. E-Lodgy’s config doesn’t cover framework-specific files like `resources/views` or `database/migrations`.
- How often is this package updated, and should I fork it for Laravel-specific changes?
- The package has recent activity (2024) with PHPStan integration, but maintenance depends on E-Lodgy’s roadmap. If you need Laravel-specific rules (e.g., facade overrides), fork the repo and customize `phpstan.neon` or `ecs.php`. Document your changes for team adoption. MIT license allows forking without legal risks.