解决方案不在命令中,而是在作曲家的 Application.php 中,它只是扩展了 Symfony\Component\Console\Application 并在那里设置了徽标:
class Application extends BaseApplication
{
private static $logo = ' ______
/ ____/___ ____ ___ ____ ____ ________ _____
/ / / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
/ /___/ /_/ / / / / / / /_/ / /_/ (__ ) __/ /
\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
/_/
';
public function getHelp()
{
return self::$logo . parent::getHelp();
}
}
所以我也做了同样的事情。我已经创建了我自己的
MyApplication extends Application
{
private static $name = "MyAPP";
/**
* @var string
*/
private static $logo = <<<LOGO
,:',:`,:'
__||_||_||_||__
____["""""""""""""""]____
\ " '''''''''''''''''''' |
~^~^~^^~^~^~^~^~^~^~^~~^~^~^^~~^~^~^~^
LOGO;
/**
* MyApp constructor.
* @param KernelInterface $kernel
* @param string $version
*/
public function __construct(KernelInterface $kernel, $version)
{
parent::__construct($kernel);
$this->setName(static::$name);
$this->setVersion($version);
}
/**
* @return string
*/
public function getHelp()
{
return static::$logo . parent::getHelp();
}
}
并在我的app/console中使用它:
$kernel = new AppKernel($env, $debug);
$application = new MyApplication($kernel, '1.0.2');
$application->run($input);
现在
$ ./app/console/ 打印:
,:',:`,:'
__||_||_||_||__
____["""""""""""""""]____
\ " '''''''''''''''''''' |
~^~^~^^~^~^~^~^~^~^~^~~^~^~^^~~^~^~^~^
MyAPP version 1.0.2