Download the PHP package matviib/notifier without Composer
On this page you can find all versions of the php package matviib/notifier. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download matviib/notifier
More information about matviib/notifier
Files in matviib/notifier
Package notifier
Short Description NO LIBRARIES socket per page bridge for your Laravel application.
License MIT
Homepage https://matviib.com/notifier
Informations about the package notifier
Base concepts
You don't need socket.io, pusher.js, jQuery, bootstrap, node.js, vue.js to start using this package.
This package can be used for sending data synchronously to each user.
This package sends data ONLY to named routes declared as GET
.
You will get your own socket server on back-end and your clients will connect to it directly, without any third-party requests to be send.
You will have pretty notifications from scratch.
To view available routes you can run php artisan notifier:init show
command. It will display available routes in the table and initiate the socket server.
Code | Description |
---|---|
event(new Notify($data)); |
- send to all routes. |
event(new Notify($data, $routes)); |
- send to routes in $routes array. |
event(new Notify($data, $routes, $users)); |
- send to routes in $routes and only to users in $users . |
Installation
For Laravel < 5.5 add provider to config/app.php
For publish notifier config file and js file for notifications out of the box:
and choose "Provider: MatviiB\Notifier\NotifierServiceProvider" if requested.
Starting server
Add worker daemon for process with Supervisor,
OR
Just run in terminal.
If you use SSL you need add to your nginx
configuration file to server block:
Usage
At first you need to add @include('notifier::connect')
before using socket.addEventListener()
in your view or main layout to use it on ALL pages.
If you want use notifications from the scratch you need to add @include('notifier::connect_and_show')
to the view.
Anywhere in your back-end add next event:
event(new Notify($data));
On front-end part add event listener
Use built-in notifications.
Built-in notifications is a vue.js with vue-notifications plugin. If you already use vue.js in application you can just add this plugin yourself.
Mapping $data
parameter.
Parameter | Description |
---|---|
'note' => 1, |
- use notes true |
'type' => 'warn|success|error|info', |
- type of note |
'title' => 'TEXT' |
- title of the note |
'text' => 'Lorem ipsum' |
- note's body |
Positioning.
In config/notifier.php
you can modify position where notifications will be shown.
Security
This package allows one way messages - only from server to client.
All messages from client after connecting will be ignored.
From server side messages protected with socket_pass parameter from notifier config.
Channels to users protected with unique hash.
Example with charts
After installation add to web.php
create view /resources/views/chart.blade.php
In .env fix your APP_URL APP_URL=http://<<U APP URL>>
Create test command php artisan make:command Test
Run: php artisan notifier:init
Run in another shell: php artisan test
Open /chart
page.
Usage Example
Send new values to chart on some page synchronously to each user:
event(new Notify($data, ['chart']));
Or to users with id
3 and 5: event(new Notify($data, ['chart'], [3, 5]));