symfony/symfony · error · LogicException
You cannot use the "Symfony\Bridge\Doctrine\Form\DoctrineOrm
Error message
You cannot use the "Symfony\Bridge\Doctrine\Form\DoctrineOrmTypeGuesser" class as the "symfony/form" package is not installed. Try running "composer require symfony/form".
What it means
Thrown at class-load time when DoctrineOrmTypeGuesser.php is autoloaded but the symfony/form package (FormTypeGuesserInterface) is not installed (DoctrineOrmTypeGuesser.php:39-41). The guesser implements FormTypeGuesserInterface, so without the Form component the class cannot exist; Symfony fails fast with an actionable message.
Source
Thrown at src/Symfony/Bridge/Doctrine/Form/DoctrineOrmTypeGuesser.php:40
use Doctrine\Persistence\Proxy;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\Extension\Core\Type\DateIntervalType;
use Symfony\Component\Form\Extension\Core\Type\DateTimeType;
use Symfony\Component\Form\Extension\Core\Type\DateType;
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
use Symfony\Component\Form\Extension\Core\Type\NumberType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\TimeType;
use Symfony\Component\Form\FormTypeGuesserInterface;
use Symfony\Component\Form\Guess\Guess;
use Symfony\Component\Form\Guess\TypeGuess;
use Symfony\Component\Form\Guess\ValueGuess;
if (!interface_exists(FormTypeGuesserInterface::class)) {
throw new \LogicException('You cannot use the "Symfony\Bridge\Doctrine\Form\DoctrineOrmTypeGuesser" class as the "symfony/form" package is not installed. Try running "composer require symfony/form".');
}
class DoctrineOrmTypeGuesser implements FormTypeGuesserInterface
{
private array $cache = [];
public function __construct(
protected ManagerRegistry $registry,
) {
}
public function guessType(string $class, string $property): ?TypeGuess
{
if (!$ret = $this->getMetadata($class)) {
return new TypeGuess(TextType::class, [], Guess::LOW_CONFIDENCE);
}
[$metadata, $name] = $ret;View on GitHub (pinned to 698e28026c)
Solutions
- Install the Form component: 'composer require symfony/form'.
- If you intentionally do not use forms, remove the DoctrineOrmTypeGuesser service/tag from your config and any code referencing it.
- Clear the cache after changing dependencies so stale container refs don't autoload the class.
Example fix
# before: symfony/form absent, services.yaml references doctrine.orm_type_guesser composer show symfony/form # not installed -> LogicException on boot # after composer require symfony/form # or, if forms are unused, remove the DoctrineOrmTypeGuesser service from config
Defensive patterns
Strategy: validation
Validate before calling
use Symfony\Component\Form\FormTypeGuesserInterface;
if (!interface_exists(FormTypeGuesserInterface::class)) {
throw new \LogicException('symfony/form missing — cannot use DoctrineOrmTypeGuesser');
} Type guard
function formComponentInstalled(): bool {
return interface_exists(\Symfony\Component\Form\FormTypeGuesserInterface::class);
} Try / catch
// Avoid referencing the class when the component is absent
if (class_exists(\Symfony\Bridge\Doctrine\Form\DoctrineOrmTypeGuesser::class, false)) { /* safe */ } Prevention
- Keep symfony/* bundles version-aligned in composer.json.
- CI: assert interface_exists(FormTypeGuesserInterface) when doctrine-bridge form guesser is wired.
- Remove unused guesser service tags if you drop symfony/form.
When it happens
Trigger: Autoloading Symfony\Bridge\Doctrine\Form\DoctrineOrmTypeGuesser (e.g. it is referenced in service configuration, a bundle autoconfig, or code) while symfony/form is not in composer.json. The `if (!interface_exists(FormTypeGuesserInterface::class))` guard fires at file load.
Common situations: Installing symfony/doctrine-bridge without symfony/form; an API-only skeleton that dropped form but left the guesser wired in services.yaml; DoctrineBundle default config referencing the guesser.
Related errors
- Not defining the IdReader explicitly as a value callback whe
- Class "%s" seems not to be a managed Doctrine entity. Did yo
- You cannot use the "%s" if the ExpressionLanguage component
- Cannot find mapping for "%s": use the #[MapEntity] attribute
- Cannot find mapping for "%s": declare one using either the #
AI-assisted analysis of symfony/symfony@698e28026c (2026-08-06).
Data as JSON: /api/errors/82f9dab6908ed225.
Report an issue: GitHub.