- Can this plugin work with Laravel’s default PHPUnit or Pest test suites?
- No, this plugin is designed specifically for PHPSpec. If your Laravel project uses PHPUnit or Pest, you’ll need to stick with those frameworks or explore alternatives like custom PHP_CodeSniffer sniffs for static analysis. The plugin bridges PHPSpec with PHP_CodeSniffer, so it won’t integrate directly with Laravel’s native testing tools.
- What Laravel versions does this plugin support? Does it conflict with Laravel’s testing helpers?
- The plugin itself doesn’t enforce Laravel version compatibility—it depends on PHPSpec and PHP_CodeSniffer. However, PHPSpec may not fully align with Laravel’s testing conventions (e.g., Artisan commands, Eloquent assertions). Test isolation could be tricky, especially if your specs rely on Laravel’s service container or database interactions. Always validate in a staging environment.
- How do I install and configure this in a Laravel project?
- Install via Composer: `composer require netzmacht/phpspec-phpcq-plugin`. Configure PHP_CodeSniffer to include the plugin’s rules in your `phpcs.xml` or `.php-cs-fixer.dist.php`. You’ll also need PHPSpec installed (`composer require phpspec/phpspec`) and a `phpcq` setup (e.g., `composer require php-cq/phpcq`). No Laravel-specific configuration exists, so you’ll need to script PHPSpec runs in your CI pipeline.
- Will this plugin break Laravel’s existing static analysis tools like PHPStan or Pint?
- No, it won’t conflict directly, but it adds another layer to your CI pipeline. PHP_CodeSniffer and PHPSpec operate independently of PHPStan or Pint. However, running multiple static analyzers could slow down your pipeline. Prioritize tools based on your needs—use PHPStan for type safety, Pint for coding standards, and this plugin for BDD-style static expectations.
- Can I use this for pre-commit hooks in Laravel?
- Yes, but you’ll need to set up a custom script to run PHPSpec and PHP_CodeSniffer via the plugin. Tools like `roave/infection` or `pre-commit` hooks can trigger `./vendor/bin/phpcq` or a Composer script. However, PHPSpec’s setup might be overkill for pre-commit—consider lighter alternatives like Pest + PHP_CodeSniffer sniffs for faster feedback.
- Does this plugin support Laravel-specific code like Blade templates or Facades?
- No, the plugin focuses on PHPSpec’s behavior-driven expectations, which are primarily for PHP classes. Blade templates or Facades won’t be analyzed unless you’ve written PHPSpec specs for the underlying logic. For Laravel-specific static analysis, tools like `nunomaduro/collision` (for Facades) or custom PHP_CodeSniffer sniffs are better suited.
- How does this compare to using Pest for BDD-style testing in Laravel?
- Pest is Laravel’s native BDD-friendly testing framework and integrates seamlessly with Laravel’s ecosystem (e.g., Artisan, Eloquent). This plugin adds PHPSpec to PHP_CodeSniffer, which is redundant if you’re already using Pest. Pest’s `expect()` syntax is more Laravel-idiomatic, while PHPSpec requires additional tooling. If you’re invested in PHPSpec, this plugin could work, but Pest + custom sniffs is often a simpler solution.
- What happens if PHPSpec specs fail in CI? Can I configure failure thresholds?
- The plugin integrates PHPSpec failures into PHP_CodeSniffer’s output, so failures will trigger based on your `phpcq` or CI configuration. You can set thresholds in your CI tool (e.g., GitHub Actions) to fail the pipeline on PHPSpec errors or warnings. However, since this isn’t Laravel-native, you’ll need to manually script the behavior in your workflow files.
- Is this plugin actively maintained? What if I encounter issues?
- The package has **0 stars and no visible maintenance activity**, which is a red flag. Issues may go unaddressed, and compatibility with newer Laravel or PHPSpec versions isn’t guaranteed. Before adopting, fork the repo or consider alternatives like `phpstan/extension-installer` for static analysis or Pest for BDD testing. Always test in a staging environment first.
- Can I use this alongside Laravel’s Pint or Larastan for coding standards?
- Yes, but they serve different purposes. Pint handles code formatting (PSR-12), Larastan handles type analysis, and this plugin adds PHPSpec-driven static expectations. However, running all three in CI could slow down your pipeline. Prioritize tools: use Pint for formatting, Larastan for types, and this plugin only if you need PHPSpec’s BDD-style static checks.