Installation:
composer require hiqdev/hidev-php-cs-fixer
Ensure hiqdev/hidev is also installed as a dependency.
Enable the Plugin:
Add to .hidev/config.yml:
plugins:
- hiqdev/hidev-php-cs-fixer
First Use Case:
Run the php-cs-fixer command via HiDev:
hidev php-cs-fixer fix
This generates a .php_cs config file (if missing) and applies fixes to your codebase.
Integrate with HiDev Commands: Use the plugin’s built-in commands for common tasks:
# Fix all files in the project
hidev php-cs-fixer fix
# Check files without fixing
hidev php-cs-fixer check
# Stop a running fix (if needed)
hidev php-cs-fixer stop-fix
Customize .php_cs Config:
The plugin auto-generates a .php_cs file in your project root. Override it by:
# .hidev/config.yml
hiqdev/hidev-php-cs-fixer:
config:
rules:
- '@PSR2'
- 'no_unused_imports'
- 'concat_space'
finder:
- path: 'src'
- path: 'tests'
CI/CD Integration: Add to your CI pipeline (e.g., GitHub Actions):
- name: Run PHP-CS-Fixer
run: hidev php-cs-fixer check
Pre-Commit Hooks:
Use with tools like pre-commit to enforce consistency:
# .pre-commit-config.yaml
repos:
- repo: local
hooks:
- id: php-cs-fixer
name: PHP-CS-Fixer
entry: hidev php-cs-fixer check
language: system
pass_filenames: false
Outdated HiDev Compatibility:
hiqdev/hidev version matches the plugin’s requirements.Config File Overrides:
.php_cs on first run. Manual edits may be overwritten. Use HiDev’s config system (as shown above) for customizations.Cache File Ignoring:
.php_cs.cache in VCS (e.g., .gitignore). Ensure this file is excluded to avoid bloating your repo.Command Path Issues:
php-cs-fixer from the project root. If you encounter path errors, verify:
php-cs-fixer is installed globally or via Composer (composer require friendsofphp/php-cs-fixer).hidev command is executed from the correct directory.Verbose Output:
Use --verbose for debugging:
hidev php-cs-fixer fix --verbose
Dry Runs: Test changes without modifying files:
hidev php-cs-fixer check --dry-run
Custom Rules: Extend the default rules by merging with the plugin’s config:
# .hidev/config.yml
hiqdev/hidev-php-cs-fixer:
config:
rules:
'@Symfony': true
'array_syntax': 'short'
Custom Templates:
Override the .php_cs template by extending the plugin’s config:
# .hidev/config.yml
hiqdev/hidev-php-cs-fixer:
template: 'path/to/custom/php_cs.template'
Post-Fix Hooks:
Use HiDev’s after hooks to run additional tasks post-fix:
# .hidev/config.yml
hooks:
after:
'php-cs-fixer/fix':
- 'git add .'
- 'git commit -m "Apply PHP-CS-Fixer fixes"'
Parallel Processing: For large codebases, leverage PHP-CS-Fixer’s parallel mode via the config:
hiqdev/hidev-php-cs-fixer:
config:
parallel: true
How can I help you explore Laravel packages today?