PHP code example of jdr / event-recorder

1. Go to this page and download the library: Download jdr/event-recorder 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/ */

    

jdr / event-recorder example snippets

 php

namespace JDR\App\Entity;

use JDR\EventRecorder\ContainsRecordedEvents;
use JDR\EventRecorder\EventRecorderCapabilities;

class Entity implements ContainsRecordedEvents
{
    use EventRecorderCapabilities;

    public function doSomething()
    {
        // ...

        $this->record(new SomethingHappened());
    }
}

$entity = new Entity();
$entity->doSomething();

// ...

$events = $entity->releaseEvents();
 php

namespace JDR\App;

use JDR\EventRecorder\EventRecorder;

$recorder = new EventRecorder();
$recorder->record(new SomethingHappened());

// ...

$events = $recorder->releaseEvents();