Php 如何在编译artisan控制台时动态加载?
这是我的密码Php 如何在编译artisan控制台时动态加载?,php,laravel,dynamic,compilation,Php,Laravel,Dynamic,Compilation,这是我的密码 namespace App\Console\Commands; use Illuminate\Console\Command; use Illuminate\Support\Facades\Redis; use App\Events\RedisEvent; class RedisSubscribe extends Command { protected $signature = 'redis:subscribe'; protected $description
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Redis;
use App\Events\RedisEvent;
class RedisSubscribe extends Command
{
protected $signature = 'redis:subscribe';
protected $description = 'Subscribe redis channel for socket communication';
protected $redisSubClient;
protected $redisCacheClient;
public function __construct()
{
parent::__construct();
$this->redisSubClient = Redis::connection('redis_socket_sub');
$this->redisCacheClient = Redis::connection('redis_cache');
}
public function handle()
{
$this->redisSubClient->subscribe(['fromClient'], function($data) {
if($this->redisCacheClient->get(config('lunachat.yellow_id').'_socket_mode') == 1) {
$par = [
'
'
'
'
'
];
event(new RedisEvent($par));
}
}
} catch (\Exception $e) {
}
});
}
}
这是eventlistener
class RedisEventListener
{
public $par;
public function __construct()
{
//
}
public function handle(RedisEvent $event)
{
$this->par = $event->par;
$api = new Api();
if ($api->find($this->par['id'])) {
$api->apiCallWrite($this->par);
}
}
}
我的问题是,当我运行这个程序时,所有与事件相关的代码都将一起加载和运行
因此,如果我修改了相关代码,我必须重新启动程序
但是,我的服务条件并非如此
由于这个原因,这个程序只编译和执行代码,直到执行事件为止,后续的逻辑需要动态编译和执行
我想知道这在拉雷维尔是否可行