PHP code example of khairy / laravel-sse-stream

1. Go to this page and download the library: Download khairy/laravel-sse-stream library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

khairy / laravel-sse-stream example snippets


Khairy\LaravelSSEStream\SSEServiceProvider::class,

'SSE' => Khairy\LaravelSSEStream\Facades\SSEFacade::class,

@

/**
 * @param string $message : notification message
 * @param string $type : alert, success, error, warning, info
 * @param string $event : Type of event such as "EmailSent", "UserLoggedIn", etc
 */
SSEFacade::notify($message, $type = 'info', $event = 'message')

use Khairy\LaravelSSEStream\Facades\SSEFacade;

public function myMethod()
{
    SSEFacade::notify('hello world....');
    
    // or via helper
    sse_notify('hi there');
}

SSEFacade::notify($message, $type = 'notification', $event = 'message')

use Khairy\LaravelSSEStream\Facades\SSEFacade;

public function myMethod()
{
    SSEFacade::notify('hello world....', 'notification', 'login');
    
    // or via helper
    sse_notify('hi there', 'notification', 'login');
}
bash
php artisan vendor:publish --provider="Khairy\LaravelSSEStream\SSEServiceProvider"