- Can I use this package with Laravel 10 and PHP 8.2+?
- The package hasn’t been updated since 2020, so PHP 8.2+ and Laravel 10 compatibility isn’t guaranteed. Test in a staging environment first, or fork the package to patch any breaking changes in Symfony’s DI components.
- How do I define a service that needs Laravel’s AppServiceProvider bindings?
- This package only works within Behat’s container—it won’t access Laravel’s production services. For shared dependencies, manually pass Laravel’s bindings (e.g., via constructor arguments) or use a wrapper service defined in Behat’s config.
- Will this work with Behat 4+ or only older versions?
- The package was built for Behat 3.x, and Behat’s container API has evolved since then. If you’re on Behat 4+, check for deprecation warnings or consider a maintained fork like `behat/symfony-extension` for modern DI support.
- Can I reuse Laravel’s config paths (e.g., %paths.config%) in behat.yml?
- Yes! The package supports Laravel’s path variables (e.g., `%paths.config%/behat/services.yml`), so you can keep service definitions alongside Laravel’s existing config structure for consistency.
- How do I inject a service into a Behat context or step definition?
- Type-hint the service in your context’s constructor. For example, `public function __construct(private TestApiClient $client) {}` will automatically resolve the service if it’s defined in your imported YAML/XML/PHP config.
- Is there a risk of service conflicts between Laravel and Behat?
- No, this package operates in Behat’s isolated container. However, if you manually instantiate Laravel services (e.g., `new AppService()`) in Behat, they won’t be managed by the container, which could lead to inconsistencies.
- Can I use this with Laravel’s Pest or PHPUnit instead of Behat?
- This package is Behat-specific. For Pest/PHPUnit, consider Laravel’s built-in `bind()` method in `AppServiceProvider` or third-party packages like `orchestra/testbench` for test-specific DI.
- How do I handle singleton vs. prototype services in Behat?
- By default, services are singletons. For prototypes, define them explicitly in your YAML/XML/PHP config (e.g., `public: false` in YAML or `<prototype>` in XML). Document scoping rules in your team’s test conventions.
- Do I need to install this in production or only in CI/dev?
- Install it in `--dev` scope only. Ensure your CI pipeline runs `composer install --dev` before Behat tests to avoid missing dependencies.
- What’s the best way to migrate from manual service instantiation to this package?
- Start by identifying hardcoded services in your Behat tests (e.g., `new TestApiClient()`). Replace them incrementally: define the service in `services.yml`, update the context’s constructor, and refactor one test file at a time.