{"record":{"id":"fe1ece2e3e5aea27","repo":"symfony/translation","slug":"you-cannot-use-s-as-the-symfony-finder-package-is-not","errorCode":null,"errorMessage":"You cannot use \"%s\" as the \"symfony/finder\" package is not installed. Try running \"composer require symfony/finder\".","messagePattern":"You cannot use \"(.+?)\" as the \"symfony/finder\" package is not installed\\. Try running \"composer require symfony/finder\"\\.","errorType":"exception","errorClass":"LogicException","httpStatus":null,"severity":"error","filePath":"Extractor/PhpAstExtractor.php","lineNumber":79,"sourceCode":"        }\n    }\n\n    public function setPrefix(string $prefix): void\n    {\n        $this->prefix = $prefix;\n    }\n\n    protected function canBeExtracted(string $file): bool\n    {\n        return 'php' === pathinfo($file, \\PATHINFO_EXTENSION)\n            && $this->isFile($file)\n            && preg_match('/\\bt\\(|->trans\\(|TranslatableMessage|Symfony\\\\\\\\Component\\\\\\\\Validator\\\\\\\\Constraints/i', file_get_contents($file));\n    }\n\n    protected function extractFromDirectory(array|string $resource): iterable|Finder\n    {\n        if (!class_exists(Finder::class)) {\n            throw new \\LogicException(\\sprintf('You cannot use \"%s\" as the \"symfony/finder\" package is not installed. Try running \"composer require symfony/finder\".', static::class));\n        }\n\n        return (new Finder())->files()->name('*.php')->in($resource);\n    }\n}\n","sourceCodeStart":61,"sourceCodeEnd":85,"githubUrl":"https://github.com/symfony/translation/blob/ae9e8a51bc29780d63c7f9efd6005d7c875e100b/Extractor/PhpAstExtractor.php#L61-L85","documentation":"PhpAstExtractor::extractFromDirectory() uses symfony/finder's Finder to iterate PHP files in the given directories. If the Finder class does not exist (package not installed), it throws LogicException with the composer require hint.","triggerScenarios":"Calling extract() with a directory resource on an install lacking symfony/finder; the finder package was made optional and your install skipped it.","commonSituations":"Translation extraction over directories in a slimmed-down deployment; version upgrade where symfony/finder moved from required to suggested; custom tooling instantiating PhpAstExtractor directly.","solutions":["Run: composer require symfony/finder","Ensure the package is in the require (not suggest/dev) section if you extract from directories","Extract from individual file resources instead of directories (if feasible)"],"exampleFix":"// before (shell)\nphp bin/console translation:extract en --dir=src\n// after (shell)\ncomposer require symfony/finder\nphp bin/console translation:extract en --dir=src","handlingStrategy":"fallback","validationCode":"if (!class_exists(\\Symfony\\Component\\Finder\\Finder::class)) {\n    // skip directory extraction or require the package\n}","typeGuard":"function hasFinder(): bool {\n    return class_exists(\\Symfony\\Component\\Finder\\Finder::class);\n}","tryCatchPattern":"try {\n    $extractor->extract('src/', $catalogue);\n} catch (\\LogicException $e) {\n    throw new \\RuntimeException('Run: composer require symfony/finder', 0, $e);\n}","preventionTips":["Require symfony/finder in composer.json when extracting from directories","Avoid --no-dev installs in translation-extraction pipelines","Pin the framework's suggested packages in a requirements check"],"tags":["php","composer","missing-dependency"],"backgroundTag":"missing-dependency","analyzedSha":"ae9e8a51bc29780d63c7f9efd6005d7c875e100b","analyzedAt":"2026-09-15T22:29:15.305Z","contentChangedAt":"2026-09-15T22:29:15.305Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}