arnislielturks/faye-client

Faye 客户端服务提供商,适用于 Laravel

0.16 2017-04-27 11:36 UTC

This package is auto-updated.

Last update: 2024-09-06 09:53:14 UTC


README

这是一个用于https://github.com/nchaulet/faye-client优秀库的包装器。旨在用于 Laravel 5+ 应用程序

安装

  1. 通过 composer 安装此包
composer require arnislielturks/faye-client
  1. 在 config/app.php 中注册提供者
// 'providers' => [
   ArnisLielturks\FayeClient\FayeServiceProvider::class,
// ];
  1. 添加配置文件(config/faye.php),内容如下。这应指向 Faye 服务
return [
    'server' => 'http://127.0.0.1:8000',
    'token' => 'your-token-here'
];
  1. 初始化并使用 Faye 客户端
namespace App\Http\Controllers;

use Illuminate\Http\Request;
use ArnisLielturks\FayeClient\FayeServiceInterface;

class TestController extends Controller
{
    protected $faye;
    
    public function __construct(FayeServiceInterface $faye)
    {
        $this->faye = $faye;
    }

    public function sendFayeMessage()
    {
        $this->faye->send('/test', ['message'=>'test'], ['token' => '123']);
    }
}

就这样!