- What Laravel-specific rules does this coding standard enforce beyond PSR-12?
- The package likely includes DosFarma’s internal conventions for Laravel, such as naming conventions for Eloquent models, service container bindings, or Blade template formatting. However, the exact rules aren’t documented in the provided details, so review the PHPCS configuration file (`ruleset.xml`) for specifics. If no Laravel-specific rules exist, it may just extend PSR-12 with DosFarma’s PHP preferences.
- How do I install and configure this coding standard for a Laravel project?
- Run `composer require --dev dosfarma/coding-standard` to install. Configure PHP_CodeSniffer to use the standard by adding a `phpcs.xml` file in your project root with `<config name="standard" value="DosFarma"/>. For Laravel, also ensure PHPCS scans Blade files by adding `<file>*.blade.php</file>` to the ruleset. No Laravel-specific dependencies are required.
- Does this package work with Laravel Pint or other PHP formatters?
- This is a PHPCS standard, not a formatter like Pint. You can use both: run PHPCS for static analysis (e.g., coding style violations) and Pint for auto-formatting. However, conflicts may arise if PHPCS enforces rules that Pint doesn’t handle (e.g., method ordering). Test both tools together in CI to identify overlaps.
- What Laravel versions does this coding standard support?
- The package doesn’t explicitly state Laravel version support, but since it’s a PHPCS standard, it should work with any Laravel version that uses PHP_CodeSniffer. If the standard includes Laravel-specific rules (e.g., for route naming or middleware), ensure those align with your Laravel version’s conventions. Test with your project’s Laravel version to confirm compatibility.
- Can I disable or override specific rules without forking the package?
- Yes, PHPCS allows rule overrides via a custom `phpcs.xml` file. For example, to disable a rule, add `<rule ref="DosFarma"><exclude name="SpecificRule"/></rule>`. If the standard is too restrictive, you can also extend it by adding your own ruleset file and merging it with DosFarma’s. Forking is only necessary if the package lacks override support.
- Will this coding standard break Laravel’s built-in conventions (e.g., Blade syntax, Facades)?
- If the standard includes Laravel-specific rules, it *could* conflict with Laravel’s idioms, such as disallowing Facades or requiring specific Blade syntax. Review the ruleset for Laravel-related constraints (e.g., `DisallowFacade` or `BladeSpacing`). If conflicts exist, use PHPCS’s override mechanism or create exceptions for Laravel-specific patterns.
- How do I integrate this into GitHub Actions or other CI pipelines?
- Add a step to your CI workflow (e.g., GitHub Actions) using `squizlabs/php_codesniffer` with the DosFarma standard. Example: `phpcs --standard=DosFarma --extensions=php,blade.php app/`. Set the job to fail on errors or warnings based on your team’s preference. For performance, cache PHPCS’s installed dependencies to speed up CI runs.
- Are there alternatives if this standard is too strict or doesn’t fit my team’s workflow?
- For Laravel projects, consider `laravel-shift/php-codesniffer-standards` (Laravel-specific rules) or `dealerdirect/phpcodesniffer-composer-normalize` (for Composer.json). If you prefer auto-formatting over linting, use `laravel/pint` (PSR-12 focused). For custom rules, extend PHPCS with your own ruleset or use `phpstan/extension-installer` for static analysis.
- Does this package support Blade template files, or only PHP classes?
- The package likely supports Blade files if configured to scan `.blade.php` extensions, but this depends on the PHPCS ruleset. Check the included `ruleset.xml` for Blade-specific rules (e.g., `@if` directive spacing or `@foreach` syntax). If missing, you’ll need to add Blade file extensions manually in your `phpcs.xml` configuration.
- How can I test this coding standard locally before enforcing it in CI?
- Run `phpcs --standard=DosFarma --report=full app/` locally to audit your codebase. Use `--diff` to compare against a previous state or `--dry-run` to preview changes. For IDE integration, configure PHPStorm’s PHPCS plugin to use this standard. Start with warnings-only mode in CI to avoid blocking builds during the transition.