- Can I use Spryker Code Sniffer in a Laravel project without conflicts?
- Yes, but you’ll need to customize the ruleset.xml to exclude Laravel-specific directories (e.g., vendor/, bootstrap/, storage/) and disable Spryker-specific sniffs like Spryker.Namespaces.SprykerNamespace. The core PSR-2/PSR-12 rules align well with Laravel’s standards, so most checks will still apply.
- How do I install Spryker Code Sniffer in a Laravel project?
- Add it as a dev dependency via Composer: `composer require --dev spryker/code-sniffer`. Then run `php artisan code:sniff:style` for checks or `php artisan code:sniff:style -f` to auto-fix issues. For manual CLI use, invoke `vendor/bin/phpcs` with the `--standard` flag pointing to the package’s ruleset.
- Does Spryker Code Sniffer support Laravel’s Artisan CLI?
- Yes, the package integrates seamlessly with Laravel’s Artisan via the `code:sniff:style` command. You can also use it alongside existing Laravel tools like `php artisan make:controller` without conflicts, as it’s a dev-only dependency.
- Will this break my existing Laravel coding standards?
- No, the package enforces PSR-2/PSR-12 by default, which Laravel already follows. Spryker-specific rules (e.g., namespace checks) can be disabled in ruleset.xml, so it won’t disrupt your project’s conventions unless you explicitly enable stricter SprykerStrict rules.
- Can I customize which files or directories are checked?
- Absolutely. Use the `--ignore` flag in CLI commands (e.g., `--ignore=tests/`) or define `<exclude-pattern>` tags in ruleset.xml. For Laravel, exclude `vendor/`, `bootstrap/`, and `storage/` by default to avoid false positives in auto-generated or cached files.
- Does Spryker Code Sniffer work with Laravel’s Blade templates?
- Blade files (.blade.php) may trigger false positives due to their syntax. Exclude them in ruleset.xml with `<exclude-pattern>*.blade.php</exclude-pattern>` or use the `--ignore` flag. Focus sniffs on PHP files in `app/`, `src/`, or `modules/` instead.
- How does this compare to php-cs-fixer or laravel-pint?
- Spryker Code Sniffer is stricter and more opinionated, focusing on coding standards (PSR-2/PSR-12) with additional Spryker-specific rules. For Laravel, use it alongside `php-cs-fixer` or `laravel-pint` for formatting—this package is better for linting and enforcing architectural patterns like service container annotations.
- Can I run this in CI/CD pipelines for Laravel?
- Yes, integrate it into your CI (e.g., GitHub Actions) by running `php artisan code:sniff:style` and failing the build on errors. Use `--strict` or `--error-severity=5` to enforce high-severity issues. Cache results to avoid slowdowns in local development.
- What Laravel versions and PHP versions does this support?
- The package requires PHP 8.2+, which aligns with Laravel 9/10. It has no runtime dependencies, so it works with any Laravel version as long as your PHP environment meets the minimum requirements. Test thoroughly with your Laravel version to ensure no conflicts.
- How do I handle false positives in Laravel-specific code (e.g., Facades, Eloquent)?
- Customize ruleset.xml to exclude or adjust rules for Laravel patterns. For example, disable `Spryker.MethodAnnotation` if your Facades use `@method` annotations differently. Test changes incrementally and document exclusions in your team’s coding guidelines.