Laravel Pusher Relay
Tested for Laravel 5.x only
This a package to turn a simple post request into a Pusher Notification with Laravel 5. It contains a controller to register in your routes file. It uses the normal Laravel Broadcasting configuration settings for using pusher., (*1)
This package makes use of Pusher's PHP Server., (*2)
Installation
Require this package with composer:
```composer require elegasoft/pusher-relay, (*3)
Add your Pusher credentials to your `.env` file:
```PUSHER_APP_ID=PusherAppID
PUSHER_APP_KEY=PusherAppKey
PUSHER_APP_SECRET=PusherAppSecretKey
You may need to update Laravel's default configuration:, (*4)
'options' => [
'cluster' => 'eu',
'encrypted' => true
]
Usage
Register a Route
Register a route in Routes/api.php:, (*5)
Route::post('notification', '\PusherRelay\PusherRelayController@store');
Required Fields
$rules = [
'channel' => 'required',
'event' => 'required',
'data' => 'required|array',
]
Forming a post route to PusherRelay
Example using AxiosJS:, (*6)
axios.post('http://localhost/notificatoin',[
'channel' => 'my-channel',
'event' => 'my-event',
'data' => ['message'=>'Hello World']
])