dev-master
9999999-devSimple persistence of Laravel events
MIT
The Requires
- php >=5.6.4
- laravel/framework >=5.3
by simon
database laravel composer events package persistence eventstore
Simple persistence of Laravel events
This package provides a quick and easy way to store Laravel Framework events to use for later debugging, monitoring, or analysis., (*1)
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)
Install the composer package by running the following:, (*3)
composer require ninjasimon/laravel-persistable-events
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, ],
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
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; } }
Simple persistence of Laravel events
MIT
database laravel composer events package persistence eventstore