soyuka/contexts
Add lightweight context handling to PHP/Laravel apps with soyuka/contexts. Store and retrieve per-request or runtime context data (like user, locale, tracing IDs) in a clean API to simplify logging, debugging, and cross-cutting concerns without global state.
soyuka/contexts package is a Behat extension designed to enhance custom helper steps in behavior-driven development (BDD). It fits well within a Laravel/PHP stack where BDD (Behat/Mink) is used for acceptance testing, particularly in projects requiring domain-specific language (DSL) extensions for complex workflows.Behat\Testwork\ServiceContainer\Definition\ServiceDefinition).soyuka/contexts.Given I am logged in as admin with a context-specific step.AdminContext, UserContext) to validate:
$container->setDefinition('contexts', new ServiceDefinition('Soyuka\Contexts\Service'));
composer require soyuka/contexts
behat.yml to load custom contexts.src/FeatureContext/AdminContext.php).namespace FeatureContext;
use Soyuka\Contexts\Context;
class AdminContext extends Context {
public function iAmAnAdmin() {
// Custom logic (e.g., Laravel Auth::loginUsingId(1))
}
}
--tags=@contexts to validate new steps.soyuka/contexts is abandoned, forking or rewriting may be needed.CONTRIBUTING.md or wiki.@wip tags to isolate failing contexts during debugging.AdminContext extends BaseContext).PaymentContext, InventoryContext).| Failure Type | Impact | Mitigation |
|---|---|---|
| Behat Configuration Error | Tests fail silently or misreport. | Use behat --dry-run pre-commit. |
| Context Step Flakiness | Non-deterministic passes/fails. | Add @retry tags or mock dependencies. |
| Package Abandonment | No updates for critical bugs. | Fork and submit PRs upstream. |
| UI State Drift | Steps break due to frontend changes. | Use visual regression testing (e.g., Applitools). |
| Database Inconsistency | Steps assume wrong data state. | Seed isolated test databases. |
How can I help you explore Laravel packages today?