Laravel task scheduling pusher practice summary (basic configuration)

Time:2022-5-15

https://dashboard.pusher.com
First of all, I register my account on pusher’s official website and choose the operation service, because I’m used to using Vue, but I choose JS without a front end. Of course, the back end is laravel

Then go to packagyst to download and configure 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

Then the pusher file will appear under the config file

Specific configuration

    '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,
        ],

    ],

];

Because I wrote the key configuration registered from pusher in Env, you can also write it directly
Env configuration

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

This completes the basic configuration
De route activate it

Route::get('pusher/index','[email protected]');
<?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');
    }
}

In this way, monitoring information will appear every time you access the address official website on the route

Basic configuration has ended

Recommended Today

Compile and install redis6.0.5

First, install the gcc package yum install cpp yum install binutils yum install glibc yum install glibc-kernheaders yum install glibc-common yum install glibc-devel yum install gcc yum install make Second, upgrade gcc yum -y install centos-release-scl yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils scl enable devtoolset-9 bash 3. Download and install redis wget http://download.redis.io/releases/redis-6.0.5.tar.gz tar -xzvf […]