diff --git a/.gitignore b/.gitignore index 53724108..d50b31d2 100644 --- a/.gitignore +++ b/.gitignore @@ -45,6 +45,7 @@ /mkinstalldirs /modules/ /package.xml +/composer.phar /phpunit.result.cache /run-tests.php /src/.idea/ diff --git a/Couchbase/Cluster.php b/Couchbase/Cluster.php index e63aa776..19bfc882 100644 --- a/Couchbase/Cluster.php +++ b/Couchbase/Cluster.php @@ -85,8 +85,17 @@ public static function connect(string $connectionString, ClusterOptions $options return ClusterRegistry::connect($connectionString, $options); } + /** + * @throws InvalidArgumentException if runtime dependencies are missing ("protobuf" and "grpc" modules) + */ private static function enableProtostellar(): void { + if (!extension_loaded("protobuf")) { + throw new InvalidArgumentException("couchbase2:// protocol requires protobuf extension"); + } + if (!extension_loaded("grpc")) { + throw new InvalidArgumentException("couchbase2:// protocol requires grpc extension"); + } ClusterRegistry::registerConnectionHandler( "/^protostellar:\/\//", function (string $connectionString, ClusterOptions $options) { diff --git a/composer.json b/composer.json index f8ca88bf..2640f305 100644 --- a/composer.json +++ b/composer.json @@ -16,14 +16,16 @@ "email": "sergey.avseyev@gmail.com" } ], - "require": { - "ext-json": "*", + "suggest": { "ext-grpc": "^1.15", "ext-protobuf": "^3.21", "google/protobuf": "^3.21", "grpc/grpc": "^1.42", "google/common-protos": "^3.1" }, + "require": { + "ext-json": "*" + }, "require-dev": { "ext-sockets": "*", "phpunit/phpunit": "^9"