Skip to content

Commit 899c151

Browse files
committed
Throw if mongodb/mongodb package is not available when configuring handlers
1 parent b8ccd02 commit 899c151

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/DependencyInjection/MonologExtension.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,10 @@ private function buildHandler(ContainerBuilder $container, $name, array $handler
267267
case 'mongo':
268268
trigger_deprecation('symfony/monolog-bundle', '3.11', 'The "mongo" handler type is deprecated in MonologBundle since version 3.11.0, use the "mongodb" type instead.');
269269

270+
if (!class_exists('MongoDB\Client')) {
271+
throw new \RuntimeException('The "mongo" handler requires the mongodb/mongodb package to be installed.');
272+
}
273+
270274
if (isset($handler['mongo']['id'])) {
271275
$client = new Reference($handler['mongo']['id']);
272276
} else {
@@ -294,6 +298,10 @@ private function buildHandler(ContainerBuilder $container, $name, array $handler
294298
break;
295299

296300
case 'mongodb':
301+
if (!class_exists('MongoDB\Client')) {
302+
throw new \RuntimeException('The "mongodb" handler requires the mongodb/mongodb package to be installed.');
303+
}
304+
297305
if (isset($handler['mongodb']['id'])) {
298306
$client = new Reference($handler['mongodb']['id']);
299307
} else {

0 commit comments

Comments
 (0)