gpt4 book ai didi

php - Laravel Ratchet 在供应商 :publish 之后不读取配置文件

转载 作者:行者123 更新时间:2023-12-04 16:13:49 25 4
gpt4 key购买 nike

我试图让 Socket 服务器基于 laravel-ratchet .

我从 git 完成了安装步骤:

1."composer require askedio/laravel-ratchet"

2. "$ php artisan vendor:publish --provider="Askedio\LaravelRatchet\Providers\LaravelRatchetServiceProvider"

然后我在 中输入了类(class)地址app.php 像这样 :
Askedio\LaravelRatchet\Providers\LaravelRatchetServiceProvider::class,

现在从这个 help我创建了我的简单套接字 IoServer app 文件夹中的类( App/MyRatchetSocketServer ):
<?php

namespace App;


use Ratchet\ConnectionInterface;
use Askedio\LaravelRatchet\RatchetServer;

class MyRatchetSocketServer extends RatchetServer
{
public function onMessage(ConnectionInterface $conn, $input)
{
parent::onMessage($conn, $input);

if (!$this->throttled) {
$this->send($conn, 'Hello you.');

$this->sendAll('Hello everyone.');

$this->send($conn, 'Wait, I don\'t know you! Bye bye!');

$this->abort($conn);
}
}
}

然后我改变了我的 /config/ratchet.php 对此:
<?php

return [
'class' => \App\MyRatchetSocketServer::class,
'host' => '127.0.0.1',
'port' => '8989',
'connectionLimit' => false,
'throttle' => [
'onOpen' => '5:1',
'onMessage' => '20:1',
],
'abortOnMessageThrottle' => false,
'blackList' => [],
'zmq' => [
'host' => '127.0.0.1',
'port' => 5555,
'method' => \ZMQ::SOCKET_PULL,
],
];

最后一部分我将开始我的服务服务:
php artisan ratchet:serve

它给出了这个错误:
Starting WampServer server on: 0.0.0.0:8080

In RatchetServerCommand.php line 204:

Askedio\LaravelRatchet\Examples\Pusher must be an instance of Askedio\LaravelRatchet\RatchetWampServer to create a Wamp server

我的猜测是, serve 命令绕过了 Ratchet 配置文件。

如果我尝试这个:
php artisan ratchet:serve --driver=IoServer --class="App\MyRachetSocketServer::class"

错误改为:
Starting IoServer server on: 0.0.0.0:8080

In RatchetServerCommand.php line 155:

Class 'App\MyRachetSocketServer::class' not found

文件路径正确(底部图片)。不知道接下来要测试什么?!

enter image description here

我使用 Xamp , Vscode , Laravel 5.5。

最佳答案

很久以前我遇到了同样的问题

试了几次,发现是缓存问题。

试试这个 Package使用此命令清除缓存:

php artisan clear:data

或者您可以按顺序使用这些通用命令:
php artisan cache:clear
php artisan view:clear
php artisan route:clear
php artisan clear-compiled
php artisan config:cache

最后,尝试您的服务器命令,如下所示:
php artisan ratchet:serve --driver=IoServer

希望有帮助:)

关于php - Laravel Ratchet 在供应商 :publish 之后不读取配置文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51348067/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com