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
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
<?php
declare(strict_types=1);
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(
$container->get(Connection::class),
$container->get(Configuration::class)
);
$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)…