Php Laravel推送器广播不发送事件
我的应用程序有一个不寻常的广播问题,我通过Dropbox将它同步,在我的笔记本电脑上我可以运行它,它将事件发送到pusher服务器,但在我的桌面上它没有。我使用相同版本的XAMPP服务器、相同的迁移等。有人能提出任何建议吗?下面提供了代码 App\Events\TodoCreated.php 环境署署长Php Laravel推送器广播不发送事件,php,laravel,pusher,laravel-5.3,Php,Laravel,Pusher,Laravel 5.3,我的应用程序有一个不寻常的广播问题,我通过Dropbox将它同步,在我的笔记本电脑上我可以运行它,它将事件发送到pusher服务器,但在我的桌面上它没有。我使用相同版本的XAMPP服务器、相同的迁移等。有人能提出任何建议吗?下面提供了代码 App\Events\TodoCreated.php 环境署署长 BROADCAST\u驱动器=推进器 ... 推送器应用程序ID= 推键= 推手的秘密= 我使用event(new App\Events\TodoCreate($todo))触发事件,其中$
BROADCAST\u驱动器=推进器
...
推送器应用程序ID=
推键=
推手的秘密=
- 我使用
触发事件,其中event(new App\Events\TodoCreate($todo))
是$todo
App\Models\todo
- 我已在config/app.php文件中启用了BroadcastServiceProvider
- 我运行php artisan queue:work--timeout=0,查看事件是否已注册并成功运行,但在pusher调试面板上没有收到任何消息
'default' => env('BROADCAST_DRIVER', 'pusher'),
'connections' => [
'pusher' => [
'driver' => 'pusher',
'key' => env('PUSHER_KEY','xxxxxxxxxxxxxxxxx'),
'secret' => env('PUSHER_SECRET','xxxxxxxxxxxxxxxxx'),
'app_id' => env('PUSHER_APP_ID','xxxxxx'),
'options' => [
//
],
],
namespace App\Events;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
class TestEvent implements ShouldBroadcast
{
public $text;
public function __construct($text)
{
$this->text = $text;
}
public function broadcastOn()
{
return ['test-channel'];
}
}
<!DOCTYPE html>
<html>
<head>
<title>Laravel</title>
<link href="https://fonts.googleapis.com/css?family=Lato:100" rel="stylesheet" type="text/css">
<style>
html, body {
height: 100%;
}
body {
margin: 0;
padding: 0;
width: 100%;
display: table;
font-weight: 100;
font-family: 'Lato';
}
.container {
text-align: center;
display: table-cell;
vertical-align: middle;
}
.content {
text-align: center;
display: inline-block;
}
.title {
font-size: 96px;
}
</style>
</head>
<body>
<div class="container">
<div class="content">
<div class="title">Laravel 5</div>
</div>
</div>
</body>
<script src="//js.pusher.com/3.0/pusher.min.js"></script>
<script>
var pusher = new Pusher("xxxxxxxxxxxxxxxxxxxxxxxxxx")
var channel = pusher.subscribe('test-channel');
channel.bind('App\\Events\\TestEvent', function(data) {
console.log(data.text);
});
</script>
</html>
2。路由器
Route::get('/', function () {
return view('welcome');
});
Route::get('/broadcast', function() {
event(new \App\Events\TestEvent('Broadcasting in Laravel using Pusher!'));
});
"require": {...,"pusher/pusher-php-server": "^2.2",}
三,TestEvent.php
'default' => env('BROADCAST_DRIVER', 'pusher'),
'connections' => [
'pusher' => [
'driver' => 'pusher',
'key' => env('PUSHER_KEY','xxxxxxxxxxxxxxxxx'),
'secret' => env('PUSHER_SECRET','xxxxxxxxxxxxxxxxx'),
'app_id' => env('PUSHER_APP_ID','xxxxxx'),
'options' => [
//
],
],
namespace App\Events;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
class TestEvent implements ShouldBroadcast
{
public $text;
public function __construct($text)
{
$this->text = $text;
}
public function broadcastOn()
{
return ['test-channel'];
}
}
<!DOCTYPE html>
<html>
<head>
<title>Laravel</title>
<link href="https://fonts.googleapis.com/css?family=Lato:100" rel="stylesheet" type="text/css">
<style>
html, body {
height: 100%;
}
body {
margin: 0;
padding: 0;
width: 100%;
display: table;
font-weight: 100;
font-family: 'Lato';
}
.container {
text-align: center;
display: table-cell;
vertical-align: middle;
}
.content {
text-align: center;
display: inline-block;
}
.title {
font-size: 96px;
}
</style>
</head>
<body>
<div class="container">
<div class="content">
<div class="title">Laravel 5</div>
</div>
</div>
</body>
<script src="//js.pusher.com/3.0/pusher.min.js"></script>
<script>
var pusher = new Pusher("xxxxxxxxxxxxxxxxxxxxxxxxxx")
var channel = pusher.subscribe('test-channel');
channel.bind('App\\Events\\TestEvent', function(data) {
console.log(data.text);
});
</script>
</html>
4。作曲家
Route::get('/', function () {
return view('welcome');
});
Route::get('/broadcast', function() {
event(new \App\Events\TestEvent('Broadcasting in Laravel using Pusher!'));
});
"require": {...,"pusher/pusher-php-server": "^2.2",}
五,welcome.blade.php
'default' => env('BROADCAST_DRIVER', 'pusher'),
'connections' => [
'pusher' => [
'driver' => 'pusher',
'key' => env('PUSHER_KEY','xxxxxxxxxxxxxxxxx'),
'secret' => env('PUSHER_SECRET','xxxxxxxxxxxxxxxxx'),
'app_id' => env('PUSHER_APP_ID','xxxxxx'),
'options' => [
//
],
],
namespace App\Events;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
class TestEvent implements ShouldBroadcast
{
public $text;
public function __construct($text)
{
$this->text = $text;
}
public function broadcastOn()
{
return ['test-channel'];
}
}
<!DOCTYPE html>
<html>
<head>
<title>Laravel</title>
<link href="https://fonts.googleapis.com/css?family=Lato:100" rel="stylesheet" type="text/css">
<style>
html, body {
height: 100%;
}
body {
margin: 0;
padding: 0;
width: 100%;
display: table;
font-weight: 100;
font-family: 'Lato';
}
.container {
text-align: center;
display: table-cell;
vertical-align: middle;
}
.content {
text-align: center;
display: inline-block;
}
.title {
font-size: 96px;
}
</style>
</head>
<body>
<div class="container">
<div class="content">
<div class="title">Laravel 5</div>
</div>
</div>
</body>
<script src="//js.pusher.com/3.0/pusher.min.js"></script>
<script>
var pusher = new Pusher("xxxxxxxxxxxxxxxxxxxxxxxxxx")
var channel = pusher.subscribe('test-channel');
channel.bind('App\\Events\\TestEvent', function(data) {
console.log(data.text);
});
</script>
</html>
拉维尔
html,正文{
身高:100%;
}
身体{
保证金:0;
填充:0;
宽度:100%;
显示:表格;
字号:100;
字体系列:“Lato”;
}
.集装箱{
文本对齐:居中;
显示:表格单元格;
垂直对齐:中间对齐;
}
.内容{
文本对齐:居中;
显示:内联块;
}
.头衔{
字体大小:96px;
}
拉维尔5号
var推进器=新推进器(“XXXXXXXXXXXXXXXXXXXXXX”)
var通道=pusher.subscribe('test-channel');
channel.bind('App\\Events\\TestEvent',函数(数据){
console.log(data.text);
});
我希望能帮助你看来你能帮我。看看这个: