rossriley / doctrine-migrations-helper
设置工具,用于提供配置好的Doctrine迁移命令
v1.1.1
2021-03-01 16:16 UTC
Requires
- doctrine/migrations: ^1.0
- symfony/console: ^2.0 | ^3.0 | ^4.0 | ^5.0
This package is not auto-updated.
Last update: 2024-09-10 08:21:27 UTC
README
此包允许以更少的样板代码和无需配置文件的方式设置Doctrine CLI工具。
如果您希望从自己的配置/DI容器中初始化迁移而不是需要xml/yml迁移配置文件,则可能希望使用此包。
它依赖于DBAL,并且必须使用有效的DriverConnection初始化。
用法
该集合设计为直接传递给Symfony Console应用程序,用法可能如下
use DoctrineMigrationsHelper\CommandSet;
$set = new CommandSet($db_connection, $namespace, $directory);
$console->addCommands($set->getCommands());
创建的配置作为CommandSet的公共属性可用,因此可以像正常迁移配置一样进行操作。例如
use DoctrineMigrationsHelper\CommandSet;
$set = new CommandSet($db_connection);
$set->configuration->setMigrationsNamespace("Example\Namespace");
$console->addCommands($set->getCommands());
默认情况下已设置所有标准CLI工具,您可以通过手动设置自己的$set->commands
数组来覆盖此设置。
此外,如果您的DI构建迁移配置,您可以直接覆盖自动创建的配置。例如
$set = new CommandSet($container->get("db-connection"));
$set->configuration = $container->get("migrations");
$console->addCommands($set->getCommands());