mstdmstd
Новичок
Всем привет!
В моем laravel 5.7 приложении я установил cboden/ratchet
В файле app/Classes/Socket/Base/BaseSocket.php :
и консольная команда :
app/Console/Commands/ChatServer.php :
Но выполняя команду в консоле я получил ошибку:
Я что-то упустил в определениях и я ничего не записал в app.php ?
В нете я нашел совет что мне нужно установить свой service provider и зарегистрировать его .
если да, то как это сделать?
Спасибо!
В моем laravel 5.7 приложении я установил cboden/ratchet
Код:
composer.json :
"type": "project",
"require": {
...
"cboden/ratchet": "^0.4.1",
Код:
<?php
namespace App\Classes\Socket\Base;
use Rachet\MessageComponentInterface;
use Rachet\ConnectionInterface;
class BaseSocket implements MessageComponentInterface {
public function onOpen(ConnectionInterface $conn) {
}
public function onMessage(ConnectionInterface $conn, $mgs) {
}
public function onClose(ConnectionInterface $conn) {
}
public function onError(ConnectionInterface $conn, \Exception $e) {
}
}
app/Console/Commands/ChatServer.php :
Код:
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Ratchet\Http\HttpServer;
use Ratchet\Server\IoServer;
use Ratchet\WebSocket\WsServer;
use App\Classes\Socket\ChatSocket;
class ChatServer extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'chat_server:serve';
/**
* The console command description.
*
* @var string
*/
protected $description = 'chat_server description';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$this->info("Start server!");
$server= IoServer::factory(
new HttpServer(
new WsServer(
new ChatSocket()
)
),
8080
);
$server->run();
}
}
Но выполняя команду в консоле я получил ошибку:
Код:
$ php artisan chat_server:serve
Start server!
PHP Fatal error: Interface 'Rachet\MessageComponentInterface' not found in /mnt/_work_sdb8/wwwroot/lar/Votes/app/Classes/Socket/Base/BaseSocket.php on line 7
Symfony\Component\Debug\Exception\FatalErrorException : Interface 'Rachet\MessageComponentInterface' not found
at /mnt/_work_sdb8/wwwroot/lar/Votes/app/Classes/Socket/Base/BaseSocket.php:7
3|
4| use Rachet\MessageComponentInterface;
5| use Rachet\ConnectionInterface;
6|
> 7| class BaseSocket implements MessageComponentInterface {
8|
9| public function onOpen(ConnectionInterface $conn) {
10|
11| }
Whoops\Exception\ErrorException : Interface 'Rachet\MessageComponentInterface' not found
at /mnt/_work_sdb8/wwwroot/lar/Votes/app/Classes/Socket/Base/BaseSocket.php:7
3|
4| use Rachet\MessageComponentInterface;
5| use Rachet\ConnectionInterface;
6|
> 7| class BaseSocket implements MessageComponentInterface {
8|
9| public function onOpen(ConnectionInterface $conn) {
10|
11| }
В нете я нашел совет что мне нужно установить свой service provider и зарегистрировать его .
если да, то как это сделать?
Спасибо!