swoft-cloud / swoft

🚀 PHP Microservice Full Coroutine Framework
https://swoft.org
Apache License 2.0
5.58k stars 786 forks source link

Command下注解无法自动注入,需要用bean来获取 #257

Closed CodeMonkeyLuffy closed 6 years ago

CodeMonkeyLuffy commented 6 years ago
Q A
Bug report? yes
Feature request? no
Swoft version x.y.z
Swoole version 2.2.0
PHP version 7.1.12
Runtime environment Win10/Mac/CentOS 7/Ubuntu/Docker etc.

Details

找不到redis方法报错

class TestCommand
{
    /**
     * @Inject()
     * @var \Swoft\Redis\Redis
     */
    private $redis;

    /**
     * this test command
     */
    public function test(Input $input, Output $output)
    {
        $result = $this->redis->set('name', 'swoft');
        var_dump($result);
    }
huangzhhui commented 6 years ago

Command 是实现不了的,会影响 Reload 功能

jianhuihi commented 6 years ago

command process 不能使用service? 只能使用logic?

stelin commented 6 years ago

这个是两个不同的生命周期,暂时不好实现,后续想下有没有好办法!