2017 © Pedro Peláez
 

library ss-event

This library provides Server Sent Event for Laravel.

image

noisim/ss-event

This library provides Server Sent Event for Laravel.

  • Friday, October 20, 2017
  • by albanafmeti
  • Repository
  • 1 Watchers
  • 0 Stars
  • 5,234 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 12 % Grown

The README.md

This library provides Server Sent Event for Laravel. Tested on Laravel 5.5., (*1)

How to use

This package is installed via Composer. To install, simply add it to your composer.json file:, (*2)

{
    "require": {
        "noisim/ss-event": "dev-master"
    }
}

and run composer to update the dependencies composer update., (*3)

Then open your Laravel config file config/app.php and in the $providers array add the service provider for this package., (*4)

\Noisim\SSEvent\SSEventServiceProvider::class

Finally generate the configuration file running in the console:, (*5)

php artisan vendor:publish --tag=config

Laravel Controller:, (*6)

<?php
namespace App\Http\Controllers;

use Noisim\SSEvent\SSEvent;

class TestController extends Controller
{
    public function test()
    {
        $sse = new SSEvent();
        return $sse->sleepTime(10)->addEvent("event_name", function () {
            return json_encode(["hello" => "world"]);
        })->start();
    }
}

Laravel Route:, (*7)

<?php

Route::get('test', 'TestController@test')->name("test");

Client Javascript:, (*8)


var source = new EventSource('/test'); source.addEventListener('event_name', function(event) { console.log(event); }, false);

The Versions

20/10 2017

dev-master

9999999-dev

This library provides Server Sent Event for Laravel.

  Sources   Download

MIT

The Requires

 

by Alban Afmeti