2017 © Pedro Peláez
 

library laravel-session-started-event

Fires an event when a session is started in Laravel for use in service providers

image

swinburne/laravel-session-started-event

Fires an event when a session is started in Laravel for use in service providers

  • Thursday, July 13, 2017
  • by ben.swinburne
  • Repository
  • 1 Watchers
  • 0 Stars
  • 5,022 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 2 Versions
  • 67 % Grown

The README.md

Laravel Session Started Event

This package fires an event which can be used in service providers (or indeed anywhere an an application) to execute code when a session is started., (*1)

Installation

Add the service provider to the providers array in config/app.php., (*2)

'providers' => [
    ...
    Swinburne\LaravelSessionStarted\SessionStartedServiceProvider::class,
    ...
],

Replace the existing Laravel StartSession middleware with that from this package in app/Http/Kernel.php. It's in the web group by default., (*3)

Replace, (*4)

\Illuminate\Session\Middleware\StartSession::class

With, (*5)

\Swinburne\LaravelSessionStarted\Http\Middleware\StartSession::class

For example, (*6)

protected $middlewareGroups = [
    'web' => [
        ...
        \Swinburne\LaravelSessionStarted\Http\Middleware\StartSession::class,
        ...
    ]
    ...

Usage

Once installed you may listen for the following event which is fired upon session start., (*7)

\Swinburne\LaravelSessionStarted\Events\SessionStarted

For example, in the boot() method of a service provider you may listen to the event in the following way., (*8)

<?php

namespace App\Providers;

use Illuminate\Support\Facades\Event;
use Illuminate\Support\ServiceProvider;
use Swinburne\LaravelSessionStarted\Events\SessionStarted;

class AppServiceProvider extends ServiceProvider
{
    /**
    * Boot the application services.
    *
    * @return void
    */
    public function boot()
    {
        Event::listen(SessionStarted::class, function ($event) {
            echo "My session was started";
        });
    }
}

The Versions

13/07 2017

dev-master

9999999-dev

Fires an event when a session is started in Laravel for use in service providers

  Sources   Download

MIT

by benswinburne

28/06 2017

v1.0.0

1.0.0.0

Fires an event when a session is started in Laravel for use in service providers

  Sources   Download

MIT

by benswinburne