linku/feedback-symfonystyle

用于linku/feedback的Symfony CLI反馈插件

1.0.4 2023-11-29 18:24 UTC

This package is auto-updated.

Last update: 2024-08-30 01:26:54 UTC


README

SymfonyStyleFeedback是一个针对linku/feedback的插件,用于集成SymfonyStyle I/O以实现Symfony命令的反馈

安装

composer require linku/feedback-symfonystyle

使用

有关通用使用说明,请参阅linku/feedback

在您的Symfony命令中,您可以按如下方式使用它

<?php

namespace App\Command;

use Linku\SymfonyStyleFeedback\SymfonyStyleFeedback;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;

class MyCommand extends Command
{
    public static $defaultName = 'app:my-command';

    /**
     * @var MyService 
     */
    private $myService;

    public function __construct(MyService $myService)
    {
        parent::__construct();

        $this->myService = $myService;
    }
    
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $io = new SymfonyStyle($input, $output);

        $this->myService->setFeedback(
            new SymfonyStyleFeedback($io)
        );

        $this->myService->run();
    }
}