gepur-it/sic-bundle
Composer 安装命令:
composer require gepur-it/sic-bundle
包简介
Single Instance Command Bundle
README 文档
README
Single Instance Console Command Bundle
provides the ability to ban more than one command instance
add bundle in bundles.php
return [
...
GepurIt\SingleInstanceCommandBundle\SingleInstanceCommandBundle::class => ['all' => true],
...
];
to mark command as single instance, add interface to your command, and add method getLockName()
class MyCommand extends Command implements SingleInstanceInterface {
...
/**
* get`s lock name for command execution, based on input
* @param InputInterface $input
* @return string
*/
public function getLockName(InputInterface $input): string
{
return $this->getName();
}
...
}
to allow to run the same command with different args, use $input in getLockName() method
class MyCommand extends Command implements SingleInstanceInterface {
...
/**
* get`s lock name for command execution, based on input
* @param InputInterface $input
* @return string
*/
public function getLockName(InputInterface $input): string
{
return $this->getName().':'.$input->getArgument('myArg');
}
...
}
统计信息
- 总下载量: 7.92k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 13
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-06-03