2017 © Pedro Peláez
 

project laravel-persistable-events

Simple persistence of Laravel events

image

ninjasimon/laravel-persistable-events

Simple persistence of Laravel events

  • Friday, March 10, 2017
  • by ninjasimon
  • Repository
  • 1 Watchers
  • 0 Stars
  • 0 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Persistable Laravel Events

This package provides a quick and easy way to store Laravel Framework events to use for later debugging, monitoring, or analysis., (*1)

Quickstart: 4-Step Installation

It's easy to get started storing events. With no configuration, the package will store the class name, serialized event object, and timestamp for any desired events., (*2)

Step 1: Install Composer Package

Install the composer package by running the following:, (*3)

composer require ninjasimon/laravel-persistable-events

Step 2: Add the service provider to config/app.php

As with most Laravel packages, you'll need to add the service provider to your app.php configuration file. Simply add the following line to the 'providers' array:, (*4)

// config/app.php

'providers' => [
        // ...

        PersistableEvents\PersistableEventServiceProvider::class,

 ],

Step 3: Create event database table

Run migrations to create a database table to store events. Out of the box, the package will use the database connection you have distinguished as the 'default' connection in your config/database.php file. This can be changed through the package configuration., (*5)

php artisan migrate

Step 4: Extend the PersistableEvent class

To add persistence to any event, simply extend the PersistableEvents\PersistableEvent abstract class as shown below. By default, when an event fires which extends this class, the event's class name, timestamp, and serialized object will be written to the database. These values can be changed, and/or additional values can be added by overriding getter methods., (*6)

<?php

namespace App\Events;

use App\Order;
use Illuminate\Queue\SerializesModels;
use PersistableEvents\PersistableEvent;

class OrderShipped extends PersistableEvent
{
    use SerializesModels;

    public $order;

    /**
     * Create a new event instance.
     *
     * @param  Order  $order
     * @return void
     */
    public function __construct(Order $order)
    {
        $this->order = $order;
    }
}

The Versions

10/03 2017

dev-master

9999999-dev

Simple persistence of Laravel events

  Sources   Download

MIT

The Requires

 

database laravel composer events package persistence eventstore