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');
}
}
这样每次访问路由上的地址 官网都会出现监控信息
基本配置已经结束