friendsofhyperf / pest-plugin-hyperf
The Pest Hyperf Plugin.
Fund package maintenance!
huangdijia
hdj.me/sponsors
Requires
- php: ^8.1
- ext-swoole: *
- hyperf/coordinator: ~3.1.0
- hyperf/di: ~3.1.0
- hyperf/support: ~3.1.0
- pestphp/pest: ^2.8.0
- pestphp/pest-plugin: ^2.0.1
This package is auto-updated.
Last update: 2024-10-25 03:57:44 UTC
README
This is a Pest plugin that enables your Hyperf project's Pest to run within a Swoole-based coroutine environment.
Installation
composer require friendsofhyperf/pest-plugin-hyperf --dev
Usage
php vendor/bin/pest --coroutine
# or
php vendor/bin/pest --prepend test/prepend.php --coroutine
- test/prepend.php
<?php require_once __DIR__ . '/../vendor/autoload.php'; defined('BASE_PATH') or define('BASE_PATH', dirname(__DIR__, 1)); (function () { \Hyperf\Di\ClassLoader::init(); \Hyperf\Context\ApplicationContext::setContainer( new \Hyperf\Di\Container((new \Hyperf\Di\Definition\DefinitionSourceFactory())()) ); // $container->get(Hyperf\Contract\ApplicationInterface::class); })();