1.3 KiB
1.3 KiB
name, description, globs
| name | description | globs | |
|---|---|---|---|
| backend-command | 命令行命令规范(Webman Command),支持 make/config/install/metadata/plugin |
|
文件位置
app/command/{Name}Command.php
代码模板
<?php
namespace app\command;
use app\command\BaseCommand;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
#[AsCommand(
name: '{name}',
description: '{description}',
aliases: ['{name}'],
hidden: false
)]
class {Name}Command extends BaseCommand
{
public function __invoke(InputInterface $input, OutputInterface $output): int
{
$output->writeln('Done');
return self::SUCCESS;
}
}
检查清单
- 命令名称是否 kebab-case
- 是否使用
#[AsCommand]注册命令 - 是否有描述信息
- 是否返回正确的 exit code
项目真实约定
- 当前项目命令通过
Symfony\Component\Console\Attribute\AsCommand自动注册 - 当前项目命令通常继承
app\command\BaseCommand - 现有命令普遍使用
public function __invoke(InputInterface $input, OutputInterface $output): int作为执行入口