- How do I install **phpyh/coding-standard** in a Laravel project?
- Run `composer require --dev phpyh/coding-standard` to install the package. It depends on PHP_CodeSniffer, so ensure it’s installed globally or via Composer (`composer require --dev squizlabs/php_codesniffer`). The package provides a CLI tool (`./vendor/bin/phpcs`) for immediate use.
- Does this package support Laravel Blade templates?
- Yes, the package includes Blade template support. Configure it in your `phpcs.xml` by adding `<arg name="extensions" value="php,blade"/>` to ensure Blade files are checked alongside PHP. Example: `<config name="installed_paths" value="./vendor/phpyh/coding-standard"/>`.
- Will this work with Laravel 10+ and PHP 8.1+?
- Yes, **phpyh/coding-standard** is designed for PHP 8.1+ and is compatible with Laravel 10+. The package doesn’t depend on Laravel core, so it integrates seamlessly with modern Laravel projects. Verify your PHP version matches the package’s requirements (`composer show phpyh/coding-standard`).
- Can I use this in CI/CD pipelines for Laravel?
- Absolutely. Add a step to your CI (e.g., GitHub Actions) like this: `./vendor/bin/phpcs --standard=phpyh --error-severity=5 src/`. Start with `--warning-severity` to avoid blocking builds initially, then escalate to enforce strict compliance. Exclude third-party code with `--ignore=vendor/`.
- How do I customize or override the default rules?
- Override rules by extending your `phpcs.xml` config. For example, disable a rule with `<rule ref="phpyh.RuleName" severity="0"/>` or add custom rules by creating a `Sniff` class in your project. The package’s rules are opinionated but designed to be flexible for team-specific adjustments.
- Does this conflict with Laravel Pint or other formatting tools?
- While **phpyh/coding-standard** focuses on static analysis (e.g., PSR-12 compliance), Laravel Pint handles auto-formatting. Use both: Pint for formatting, this package for linting. Avoid duplicate checks by excluding Pint’s rules from your `phpcs.xml` or vice versa. Test both tools together to ensure compatibility.
- How do I handle legacy Laravel code that violates the rules?
- Start with `--warning-severity` in CI and allow gradual fixes. Use `--ignore` to exclude legacy files temporarily (e.g., `--ignore=old-migrations/`). Document exceptions in `phpcs.xml` with `<exclude-pattern>...</exclude-pattern>`. Prioritize new code for compliance while phasing out legacy violations.
- Is this package actively maintained? What’s the last update?
- The package was last updated on **2025-10-21**, indicating recent maintenance. Check the repository (if available) for changelogs or GitHub activity. For critical projects, verify compatibility with your Laravel/PHP versions and consider forking if custom rules are needed long-term.
- Can I integrate this with PHPStorm or VSCode for real-time feedback?
- Yes, install the **PHP_CodeSniffer** plugin in PHPStorm or the **PHP Intelephense** extension in VSCode. Configure the plugin to use `phpyh/coding-standard` as the default standard. This provides real-time underlining of violations and quick fixes, improving developer workflows.
- What alternatives exist for Laravel coding standards?
- Alternatives include **Laravel Pint** (for auto-formatting), **laravel-shift/blueprint** (Laravel-specific rules), or **PSR-12** via `dealerdirect/phpcodesniffer-composer-installer`. If your team uses **PHPStan** or **Rector**, coordinate to avoid redundant checks. **phpyh/coding-standard** stands out for its curated, reusable ruleset tailored for consistency.