gpt4 book ai didi

symfony - 向 LoadDataFixture 命令添加新选项

转载 作者:行者123 更新时间:2023-12-04 08:47:31 25 4
gpt4 key购买 nike

我想为我的 doctrine:fixtures:load 控制台命令添加一个新选项。

class LoadDataFixturesCommand extends LoadDataFixturesDoctrineCommand 
{
/**
* {@inheritDoc}
*/
protected function configure()
{
parent::configure();

$this->addOption('custom', null, InputOption::VALUE_OPTIONAL, 'Your Custom Option');
}
}

当我这样运行我的命令时:

doctrine:fixtures:load --custom

我收到此错误消息:

[Symfony\Component\Console\Exception\RuntimeException]
The "--custom" option does not exist.

如何将此选项添加到我的控制台命令?

最佳答案

您可以重命名函数:

protected function configure()
{
parent::configure();

$this->setName('app:fixtures:load')
->addOption('custom-option', null, InputOption::VALUE_OPTIONAL, 'Your Custom Option');
}

这条路上的命令

php app/console app:fixtures:load 

将调用您的个人执行函数。

关于symfony - 向 LoadDataFixture 命令添加新选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41480650/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com