- What is knplabs/friendly-contexts used for?
- It is a set of reusable Behat contexts for testing Symfony applications. It provides ready-made Gherkin steps and helpers for Doctrine entities, fixtures, services, email, file system checks, and API/JSON assertions so teams can reduce acceptance-test boilerplate. It is a dev-only library, not an application dependency.
- Does knplabs/friendly-contexts work with Laravel?
- Only partially. The framework-agnostic contexts such as Api, Json, and File, plus parts of Mail and Date, can map to a Laravel project, but the SymfonyContext and Doctrine contexts assume a Symfony kernel and Doctrine ORM rather than Laravel's Eloquent. You also need to add your own Laravel bootstrapping because the package does not ship a Laravel integration.
- How do I install knplabs/friendly-contexts with Composer?
- The mechanical command is composer require --dev knplabs/friendly-contexts, but on a modern Laravel project resolution is likely to fail. The package pins Behat 3.x, Symfony 2/3, abandoned fzaninotto/faker, and Guzzle 5/6, so you may need ignore-platform-reqs or forks. Running the upstream package unmodified is not recommended; copying the contexts you need is safer.
- Is knplabs/friendly-contexts compatible with PHP 8 and Laravel 10 or 11?
- No, not as published. The last release was in 2016 and targets PHP 7.x-era code, Behat 3.x, Symfony 2/3, and old Guzzle versions, so it is incompatible with supported Laravel releases as-is. A patched copy-in can be made PHP 8.1+ compatible with modest effort, but that work is yours to own.
- Which FriendlyContexts contexts can I use in a Laravel project?
- The most portable pieces are the Api, Json, and File contexts, with limited use of Date and parts of Mail. The SymfonyContext, Doctrine contexts, and Swiftmailer-era mail semantics are largely inapplicable to Laravel. In practice, expect to use roughly 40 percent of the package's surface.
- Do I need a Laravel service provider to use FriendlyContexts?
- No. Behat bootstraps outside the Laravel application, so there is no service provider to register. You do need an app-bootstrapping extension such as laracasts/behat-laravel-extension or a hand-rolled FeatureContext to expose the container, HTTP kernel, database transactions, and mail fakes.
- Can FriendlyContexts test Doctrine entities and fixtures in Laravel?
- No, not meaningfully. Laravel uses Eloquent, not Doctrine, and the Doctrine-oriented contexts assume Symfony's Doctrine integration and fixtures workflow. Those parts of the package are dead weight in a Laravel application, so do not adopt the package for entity or fixture assertions.
- How do I test emails and files with knplabs/friendly-contexts?
- The File context is a thin wrapper that can be copied and adapted for Laravel. The mail context assumes Symfony and Swiftmailer-era semantics, while Laravel's Mail::fake and related assertions supersede it. For email behavior in Laravel, use Laravel's mail fakes rather than the package's mail steps.
- What are the alternatives to knplabs/friendly-contexts for Laravel Behat testing?
- Use laracasts/behat-laravel-extension or a custom FeatureContext to bootstrap Laravel and write only the Gherkin steps you need. If your team is not standardized on Behat, Pest or PHPUnit with Laravel's HTTP test helpers, Http::fake, and Mail::fake may be a better fit. Copying the useful Api, Json, and File contexts is a practical middle ground.
- Is knplabs/friendly-contexts maintained, and what are the production risks?
- It is archived: the last release was 2016-08-05, there is no maintainer, no CVE feed, and zero dependents, though it is MIT licensed. Because it is dev-only tooling, production blast radius is zero. The real risks are CI reliability, PHP upgrade friction, and supply-chain hygiene from keeping an unmaintained dev dependency in the lockfile.