Doctrine command in Mezzio application

I’m currently working on a Mezzio application and I’m trying to figure out the best way to use Doctrine commands like migrations. I’ve been reading the documentation, but I’m still a bit confused.
Can anyone offer some advice? how i can configure doctrine command in Mezzio application


The official documentation of Mezzio does not contain anything about migrations with Doctrine, so which documentation do you mean?

If you use “Doctrine ORM Module for Laminas” then it should be something like:

./vendor/bin/doctrine-module migrations:list
1 Like

If you’re using doctrine/migrations standalone, I will normally drop something like this into config/cli-config.php and then run vendor/bin/doctrine and vendor/bin/doctrine-migrations



use Doctrine\DBAL\Connection;
use Doctrine\Migrations\Configuration\Configuration;
use Doctrine\Migrations\Tools\Console\Helper\ConfigurationHelper;
use Doctrine\ORM\Tools\Console\ConsoleRunner;

chdir(__DIR__ . '/../');
require __DIR__ . '/../vendor/autoload.php';

$container = require __DIR__ . '/container.php';
$entityManager  = $container->get('doctrine.entity_manager.orm_default');
$helperSet = ConsoleRunner::createHelperSet($entityManager);

 * Migrations
$migrationConfigHelper = new ConfigurationHelper(
$helperSet->set($migrationConfigHelper, 'configuration');

return $helperSet;

Obviously, you’ll need to make sure that the services you fetch from the container here are using the correct service identifiers / FQCNs

thank you very much…that will be good point to start…what i am trying to use laminas-cli to executed doctrine command…somthing like factory for the doctrine commands(inclusive migrations)…

thank for answes…but this doctrine module is only for laminas and will not working with Mezzio? or?

Don’t let the name mislead you, because if a config provider class is included, then you can also use this in Mezzio:

Or check the configuration for Composer: