푸시 계정을 올바르게 설정하고 환경 변수가 올바른 것으로 가정합니다.
그렇다면 올바른 클러스터를 사용하고 있는지 확인해야 할 수도 있습니다 (기본값은 미국에 적합하지만 미국 동부 해안 외부에서는 클러스터를 명시 적으로 정의해야합니다).
업데이트 :
컨트롤러 코드 : 나는 https://github.com/vinkla/laravel-pusher의 설정 단계 다음 vinkla/푸셔 새로 설치에이 작업을 가지고
Route::get('testPusherController', '[email protected]');
Route::get('shortenedTestPusherController', '[email protected]');
: 웹 루트에서
<?php
namespace App\Http\Controllers;
use Vinkla\Pusher\Facades\Pusher;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
class TestPusherController extends BaseController
{
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
public function test(){
$arr = array('test' => 'hello world 2') ;
$pusher = new Pusher(env('PUSHER_KEY'), env('PUSHER_SECRET'), env('PUSHER_APP_ID'), array('encrypted' => true, 'cluster' => 'ap1'));
$pusher::trigger('test_channel', 'my_event', $arr);
return $arr;
}
public function shortenedTest(){
$message = 'Hello world';
Pusher::trigger('my-channel', 'my-event', ['message' => $message]);
}
}
, Laravel 5.3에서 PHP 서버를 내장하고 EU 서버에 연결 (현재 ap1을 사용하는 푸셔 응용 프로그램이 없습니다).
올바른 형식을 얻으려면 컨트롤러에서 코딩을 약간 변경해야합니다. 컨트롤러 위에 푸셔 외관을 사용해야합니다.
완벽을 기하기 위해 각 사용에 대한 연결을 설정할 필요없이 Config/pusher.php 파일에서 Pusher 자격 증명을 설정할 수있는 더 좋은 방법을 추가했습니다. 이것은 컨트롤러의 shortenedTest() 메서드에서 볼 수 있습니다.
<?php
return [
'connections' => [
'main' => [
'auth_key' => env('PUSHER_KEY'),
'secret' => env('PUSHER_SECRET'),
'app_id' => env('PUSHER_APP_ID'),
'options' => [
'cluster' => env('PUSHER_CLUSTER')
],
'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,
],
],
];
이벤트는 https://dashboard.pusher.com/의 디버그 콘솔에 표시됩니까? –
아니요 어떤 이벤트도 볼 수 없습니다 –
아직 Laravel에서 이것을 사용하지는 않았지만 제 독서에서'broadcast()'메소드를 사용해서는 안됩니까? https://laravel.com/docs/5.3/broadcasting#broadcasting-events –