diff --git a/composer.json b/composer.json index 32393f9..73e44c1 100644 --- a/composer.json +++ b/composer.json @@ -38,6 +38,10 @@ "dev-master": "1.0.x-dev" } }, + "suggest": { + "php-uv": "Extension for libuv backends (high performance use cases).", + "pecl/libevent": "Extension for libevent backends (high performance use cases)." + }, "repositories": [ { "type": "vcs", diff --git a/lib/LibeventReactor.php b/lib/LibeventReactor.php index e9ab754..27ba103 100644 --- a/lib/LibeventReactor.php +++ b/lib/LibeventReactor.php @@ -22,6 +22,10 @@ class LibeventReactor implements SignalReactor { private static $instanceCount = 0; public function __construct() { + if (!extension_loaded('libevent')) { + throw new \RuntimeException('The pecl-libevent extension is required to use the LibeventReactor.'); + } + $this->base = event_base_new(); $this->gcEvent = event_new(); event_timer_set($this->gcEvent, [$this, 'collectGarbage']); diff --git a/lib/UvReactor.php b/lib/UvReactor.php index 2d68d9b..cd67256 100644 --- a/lib/UvReactor.php +++ b/lib/UvReactor.php @@ -25,6 +25,10 @@ class UvReactor implements SignalReactor { private static $instanceCount = 0; public function __construct() { + if (!extension_loaded('uv')) { + throw new \RuntimeException('The php-uv extension is required to use the UvReactor.'); + } + $this->loop = uv_loop_new(); $this->gcWatcher = uv_timer_init($this->loop); $this->gcCallback = function() { $this->collectGarbage(); };