laravel任务调度pusher实践总结(基本配置)

https://dashboard.pusher.com
首先 pusher官网注册帐号 而且选择操做服务 由于我习惯性用vue可是没有 前端就选js 后端固然是laravel php

而后 前往packalyst下载并配置pusher
https://packalyst.com/package...前端

$ composer require pusher/pusher-http-laravel

config/app.php to your aliasesvue

'Pusher' => Pusher\Laravel\Facades\Pusher::class

config/app.php in the providerslaravel

Pusher\Laravel\PusherServiceProvider::class

而后就会在config文件下出现pusher文件后端

具体配置app

'connections' => [

        'main' => [
            'auth_key' => env('PUSHER_APP_KEY'),
            'secret' => env('PUSHER_APP_SECRET'),
            'app_id' => env('PUSHER_APP_ID'),
            'options' => [
                'cluster' => 'ap1',
                'encrypted' => true
            ],
            'host' => null,
            'port' => null,
            'timeout' => null,
        ],

        'alternative' => [
            'auth_key' => 'your-auth-key',
            'secret' => 'your-secret',
            'app_id' => 'your-app-id',
            'options' => [],
            'host' => null,
            'port' => null,
            'timeout' => null,
        ],

    ],

];

由于我将从pusher注册的key配置写在了env里 你也能够直接写进去
env配置composer

PUSHER_APP_ID=489720
PUSHER_APP_KEY=be59d501087a3c4a340d
PUSHER_APP_SECRET=661f0c7f0dd0ecd86c11
PUSHER_APP_CLUSTER=ap1

这样就基本配置完毕
去路由激活它ide

Route::get('pusher/index','PusherController@index');
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class PusherController extends Controller
{
    //
    function index(){
        $pusher=app()->make('pusher');
        $pusher->trigger('wang-channel','ye-event',['message'=>'woshiwangye']);
        return view('pusher/index');
    }
}

这样每次访问路由上的地址 官网都会出现监控信息ui

基本配置已经结束spa

相关文章
相关标签/搜索