e-lodgy/coding-standard
E-Lodgy’s shared Easy Coding Standard (ECS) configuration for PHP projects. Install via Composer, import the provided ecs.php, and apply consistent formatting and code style rules across your src, tests, and config files.
Installation Update to the latest version via Composer in your Laravel project:
composer require --dev e-lodgy/coding-standard:^1.1.6
First Use Case Integrate with PHP_CodeSniffer to enforce E-Lodgy’s updated coding standards:
./vendor/bin/phpcs --standard=vendor/e-lodgy/coding-standard/src/E-Lodgy src/
Where to Look First
vendor/e-lodgy/coding-standard/ruleset.xml (updated with PHPStan integration).phpstan.neon configuration (if provided) for static analysis rules.phpcs.xml or .phpcs.xml:
<config name="standard" value="E-Lodgy"/>
CI/CD Pipeline Run in pre-commit hooks or CI (e.g., GitHub Actions), now with PHPStan support:
# .github/workflows/phpcs.yml
- name: Run PHP_CodeSniffer
run: ./vendor/bin/phpcs --standard=E-Lodgy --warning-severity=0 src/
- name: Run PHPStan
run: ./vendor/bin/phpstan analyse --level=max src/
IDE Integration Configure PHPStorm or VSCode to auto-fix issues using the updated E-Lodgy standard:
vendor/e-lodgy/coding-standard to Settings > Editor > Inspections > PHP > Code Sniffer.phpcs and integrate PHPStan via the PHPStan extension.Team Onboarding
CONTRIBUTING.md:
Before submitting PRs, run:
./vendor/bin/phpcbf --standard=E-Lodgy src/
./vendor/bin/phpstan analyse --level=max src/
phpcbf (fixer) for auto-correction and PHPStan for static analysis.Laravel-Specific Rules Leverage Laravel-specific sniffs (e.g., route naming, Blade consistency) and now also PHPStan rules for:
Rule Conflicts
phpcs.xml:
<rule ref="E-Lodgy">
<exclude name="Generic.Files.LineEndings"/>
</rule>
phpstan.neon to exclude paths or adjust levels:
includes:
- vendor/e-lodgy/coding-standard/phpstan/
excludePaths:
- src/legacy/
Performance
phpcs and phpstan. Tip: Run incrementally:
./vendor/bin/phpcs --standard=E-Lodgy src/App/Http/Controllers/
./vendor/bin/phpstan analyse --level=max src/App/Http/Controllers/ --memory-limit=1G
False Positives
<exclude> in phpstan.neon:
excludePaths:
- src/legacy/
Trailing Comma Fix
phpcbf to auto-fix:
./vendor/bin/phpcbf --standard=E-Lodgy --rules-exclude=Generic.Files.LineEndings src/
--report=full for phpcs and --debug for phpstan:
./vendor/bin/phpcs --standard=E-Lodgy --report=full src/
./vendor/bin/phpstan analyse --debug src/
Custom Rules
Extend the standard by adding your own sniffs to phpcs.xml or PHPStan rules to phpstan.neon:
<rule ref="E-Lodgy">
<config name="customRules" value="vendor/your-package/sniffs"/>
</rule>
includes:
- vendor/e-lodgy/coding-standard/phpstan/
- vendor/your-package/phpstan/
Overriding Rules
Modify the ruleset locally by copying vendor/e-lodgy/coding-standard/ruleset.xml and phpstan.neon to your project.
Integration with Laravel Tools
pint.json (complementary to phpcs/phpstan):
{
"preset": "laravel",
"rules": {
"array_syntax": "short",
"trailing_comma_in_multiline": true
}
}
--warning-severity=3 for phpcs and --level=5 for phpstan to avoid overwhelming the team.phpcbf for non-controversial fixes (e.g., trailing commas, spacing).composer.json to avoid unexpected rule changes:
"require-dev": {
"e-lodgy/coding-standard": "^1.1.6"
}
phpstan.neon is not provided, create one in your project root and extend the E-Lodgy rules:
includes:
- vendor/e-lodgy/coding-standard/phpstan/
How can I help you explore Laravel packages today?