eckinox/eckinox-cs
Eckinox CS adds linting and coding standards to PHP projects. Installs and configures PHP-CS-Fixer, PHPStan, PHPMD and more, plus JS deps, config files, helper scripts, a git pre-commit hook, and a GitHub Actions workflow.
Installation:
composer require --dev eckinox/eckinox-cs
This auto-generates config files, scripts, and hooks in your project.
Set Up Dependencies:
npm install
chmod +x DEV/**/*
First Run (Pre-Commit):
git add app/Http/Controllers/TestController.php
git commit -m "Test CS"
Manual Fixing: Run PHP-CS-Fixer directly to auto-fix issues:
./DEV/cs/php-cs-fixer
CI Integration: Push to GitHub to trigger the GitHub Actions workflow (check "Checks" tab).
composer install (installs eckinox/eckinox-cs dev dependencies)../DEV/cs/all to run all linters and fix issues.DEV/cs/ directory contains one-liners for each tool (e.g., ./DEV/cs/phpstan)..php_cs.dist, phpstan.neon, .eslintrc.json—do not edit manually (they’ll be overwritten on updates)..git/hooks/pre-commit (symlink to DEV/git-hooks/pre-commit)..github/workflows/coding-standards.yml.Pre-Commit Hooks:
./DEV/git-hooks/pre-commit-with-bypass to commit despite failures (interactive prompts per tool).git add app/Models/User.php
git commit -m "Add user model" # Fails if violations exist
Manual Linting:
./DEV/cs/php-cs-fixer --dry-run # Preview changes
./DEV/cs/php-cs-fixer --allow-risky=yes # Auto-fix
./DEV/cs/phpstan --level=max # Strictest checks
./DEV/cs/eslint
./DEV/cs/stylelint
Twig Templates:
./DEV/cs/twig-cs-fixer resources/views/*.twig
CI Feedback:
Ignoring Vendor Files:
phpstan.neon) already exclude vendor/ by default. No action needed.Blade Template Linting:
twig-cs-fixer for Blade files (treated as Twig templates):
./DEV/cs/twig-cs-fixer resources/views/**/*.blade.php
Database Migrations:
phpstan.neon includes Doctrine-specific rules (e.g., ignores TMaybeContained in collections).Artisan Command Linting:
app/Console/:
./DEV/cs/phpstan app/Console/
Custom Rules Without Overwriting Configs:
.php_cs (for PHP-CS-Fixer) or phpstan.neon without the .dist suffix in the root. The package will merge these with its defaults.includes:
- %vendor_dir%/eckinox/eckinox-cs/phpstan.neon
- phpstan.neon # Your custom rules
Excluding Files:
.php_cs.dist or .eslintignore to exclude files/folders. Example:
# .eslintignore
/node_modules/
/resources/js/vendor/
Symfony Projects:
MissingImport for Symfony configs). Works seamlessly with Laravel’s Symfony components.Node Version Management:
package.json. Use nvm or Docker to ensure compatibility:
nvm use # Ensure Node version matches package.json engines field
Config Overwrites:
.php_cs.dist, phpstan.neon.dist, etc. These are recreated on updates..php_cs or phpstan.neon (without .dist) for customizations.Git Hook Conflicts:
pre-commit hook, the package won’t overwrite it. Merge manually or remove the old hook.rm -f .git/hooks/pre-commit
ln -s DEV/git-hooks/pre-commit .git/hooks/pre-commit
PHPStan False Positives:
TMaybeContained errors. These are intentionally ignored in the default config (see v1.7.0).Node.js Dependencies:
npm install fails, ensure Node.js is v16+ (check package.json engines field). Use:
nvm install 18
nvm use 18
GitHub Actions Authentication:
COMPOSER_AUTH to GitHub Secrets. The workflow auto-detects this secret.Dry Runs:
./DEV/cs/php-cs-fixer --dry-run --diff
./DEV/cs/phpstan --level=max --no-progress
Verbose Output:
-v or --verbose flags to scripts (e.g., ./DEV/cs/phpstan -vv).Isolate Issues:
./DEV/cs/phpstan app/Http/Controllers/UserController.php
Bypass Specific Tools:
pre-commit-with-bypass to skip failing tools interactively.Custom PHP-CS-Fixer Rules:
.php_cs:
rules:
@PhpCsFixer: true
no_unused_imports: true
PHPStan Extensions:
phpstan.neon:
includes:
- %vendor_dir%/eckinox/eckinox-cs/phpstan.neon
- vendor/your-extension/phpstan-extensions.neon
ESLint Plugins:
.eslintrc.json:
{
"plugins": ["your-plugin"],
"rules": {
"your-plugin/rule": "error"
}
}
GitHub Actions Customization:
.github/workflows/coding-standards.yml:
jobs:
coding-standards:
steps:
- uses: actions/checkout@v4
- run: ./DEV/cs/all
- run: ./DEV/cs/phpstan --level=max # Add custom steps
phpstan --generate-baseline and commit baseline.php:
./DEV/cs/phpstan --generate-baseline
git add phpstan
How can I help you explore Laravel packages today?