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

https://dashboard.pusher.com
首先 pusher官网注册账号 并且选择操作服务 因为我习惯性用vue但是没有 前端就选js 后端当然是laravel

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

$ composer require pusher/pusher-http-laravel

config/app.php to your aliases

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

config/app.php in the providers

Pusher\Laravel\PusherServiceProvider::class

然后就会在config文件下出现pusher文件

具体配置

    '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配置

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

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

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');
    }
}

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

基本配置已经结束

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值