doctrine/orm · error · InvalidArgumentException

No Result cache driver is configured on given EntityManager.

Error message

No Result cache driver is configured on given EntityManager.

What it means

orm:clear-cache:result clears the result cache via $em->getConfiguration()->getResultCache(). With no result cache configured the getter returns null (this ORM sets no default), and the command throws InvalidArgumentException rather than reporting success on a cache that does not exist.

Source

Thrown at src/Tools/Console/Command/ClearCache/ResultCommand.php:54

Alternatively, if you want to flush the cache provider using this command:

<info>%command.name% --flush</info>

Finally, be aware that if <info>--flush</info> option is passed, not all cache providers are able to flush entries,
because of a limitation of its execution nature.
EOT);
    }

    protected function execute(InputInterface $input, OutputInterface $output): int
    {
        $ui = (new SymfonyStyle($input, $output))->getErrorStyle();

        $em    = $this->getEntityManager($input);
        $cache = $em->getConfiguration()->getResultCache();

        if (! $cache) {
            throw new InvalidArgumentException('No Result cache driver is configured on given EntityManager.');
        }

        $ui->comment('Clearing <info>all</info> Result cache entries');

        $message = $cache->clear() ? 'Successfully deleted cache entries.' : 'No cache entries were deleted.';

        $ui->success($message);

        return 0;
    }
}

View on GitHub (pinned to d9b9ff7301)

Solutions

  1. Configure a result cache where you intend to clear it: $config->setResultCache($adapter) or doctrine-bundle orm result_cache_driver.
  2. If you never use result caching, remove the command from your routine.
  3. Verify in the CLI context: $em->getConfiguration()->getResultCache() !== null.

Example fix

// before
$ php bin/console doctrine:orm:clear-cache:result
// InvalidArgumentException: No Result cache driver is configured...

// after
$config->setResultCache(new Symfony\Component\Cache\Adapter\PhpFilesAdapter(
    'orm_result', 0, $cacheDir
));
Defensive patterns

Strategy: validation

Validate before calling

if ($em->getConfiguration()->getResultCache() === null) {
    // no result cache configured: nothing to clear, skip the command
    return 0;
}
// run orm:clear-cache:result

Try / catch

Catch \InvalidArgumentException around the command in deploy scripts and log 'result cache not configured' as info instead of failing the pipeline.

Prevention

When it happens

Trigger: Running orm:clear-cache:result on an EntityManager whose configuration never called setResultCache() (doctrine-bundle: result_cache_driver); apps that enable result caching per query without a global result cache; CLI kernels booting a minimal configuration.

Common situations: ORM 3 migrations where the implicit default result cache disappeared; deploy scripts clearing every cache command unconditionally; dev environments with caching disabled.

Related errors


AI-assisted analysis of doctrine/orm@d9b9ff7301 (2026-08-21). Data as JSON: /api/errors/7139b5301ddab5ae. Report an issue: GitHub.