- How does **drupol/php-conventions** improve Laravel project consistency?
- It provides pre-configured GrumPHP rulesets for PSR-12 compliance, PHPStan static analysis, and PHPCS checks—ensuring Laravel projects adhere to modern PHP standards out of the box. This reduces manual configuration and enforces consistency across teams.
- Can I use this package without GrumPHP in a Laravel project?
- Yes, but you’ll need to manually reference its config in `composer.json` under `extra.grumphp`. It’s designed to work standalone or alongside existing GrumPHP setups, making it flexible for Laravel projects with or without prior GrumPHP integration.
- Does **drupol/php-conventions** support Laravel-specific coding patterns like Facades or Blade templates?
- No, it focuses on generic PHP conventions (PSR-12, PHPStan, etc.). For Laravel-specific patterns, you’ll need to extend its PHPCS or PHPStan rulesets manually or combine it with tools like `laravel-shift/blueprint` for tailored enforcement.
- Will this package slow down my Laravel CI/CD pipeline?
- PHPStan and PHPCS can add overhead, especially for large codebases. Benchmark execution times in your CI environment and cache results (e.g., using GitHub Actions caching) to mitigate delays. Start with a subset of rules if needed.
- How do I customize the default rules for my Laravel project?
- Override the YAML config file (`grumphp.yml`) or extend the imported `drupol/php-conventions` config. Use `skip_tasks` to disable defaults (e.g., `phpcsfixer`) and add Laravel-specific tasks via `extra_tasks` or custom scripts.
- Does this package work with Laravel 8+ and PHP 8.x?
- Yes, it supports PHP 7.3+ and aligns with Laravel 8+’s PSR-12 compliance. Choose the `php73`, `php80`, or `psr12` config preset during installation to match your Laravel project’s PHP version and requirements.
- How do I integrate this with Laravel’s built-in tools like `pint` or `phpstan/extension-installer`?
- Use `pint` for auto-formatting to reduce PHPCS noise, and `phpstan/extension-installer` for PHPStan extensions. Configure `drupol/php-conventions` to skip redundant tasks (e.g., `phpcsfixer` if using `pint`) and focus on static analysis.
- Can I run specific checks (e.g., only PHPStan) in a Laravel project?
- Yes, use GrumPHP’s `--testsuite` or `--tasks` flags. For example, run `vendor/bin/grumphp run --tasks=phpstan` to target only static analysis, or `--testsuite=cs` for code style checks.
- What alternatives exist for Laravel projects needing code conventions?
- Consider `laravel/pint` for formatting, `phpstan/extension-installer` for PHPStan, or `dealerdirect/phpcodesniffer-composer-installer` for PHPCS. For all-in-one solutions, `drupol/php-conventions` combines these but lacks Laravel-specific features.
- How do I handle rule violations in a Laravel team workflow?
- Configure GrumPHP to fail builds on violations (CI) or block commits (Git hooks). For Laravel, document exceptions for legacy code or use `skip_tasks` temporarily. Pair with `rector/rector` to automate fixes for recurring issues.