Skip to content

Commit 5e7405e

Browse files
committed
Add a check to the builder class
1 parent 6e8e705 commit 5e7405e

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

src/Server/Builder.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
use Psr\Log\LoggerInterface;
4747
use Psr\Log\NullLogger;
4848
use Psr\SimpleCache\CacheInterface;
49+
use Symfony\Component\Finder\Finder;
4950

5051
/**
5152
* @phpstan-import-type Handler from ElementReference
@@ -523,8 +524,12 @@ public function build(): Server
523524
);
524525

525526
if (null !== $this->discoveryBasePath) {
526-
$discoverer = $this->discoverer ?? $this->createDiscoverer($logger);
527-
$loaders[] = new DiscoveryLoader($this->discoveryBasePath, $this->discoveryScanDirs, $this->discoveryExcludeDirs, $discoverer);
527+
if (null !== $this->discoverer || class_exists(Finder::class)) {
528+
$discoverer = $this->discoverer ?? $this->createDiscoverer($logger);
529+
$loaders[] = new DiscoveryLoader($this->discoveryBasePath, $this->discoveryScanDirs, $this->discoveryExcludeDirs, $discoverer);
530+
} else {
531+
$logger->warning('File-based discovery requires symfony/finder. Skipping automatic discovery. Run: composer require symfony/finder');
532+
}
528533
}
529534

530535
foreach ($loaders as $loader) {

0 commit comments

Comments
 (0)