Event Stream

That is the most powerful feature of Fault Manager, the ability to provide Exceptions that would be added into Event Stream and attach handler for all Exceptions or additionally to specific exceptions.

Enabling Event Stream

In order to enable Event Stream you simply need to type the following command:

Fault::enableEventStream();

You can check if Event Stream is enabled with

Fault::isEventStreamEnabled();

If you want to disable Event Stream you can use

Fault::disableEventStream();

Note

When Event Stream is Enabled, custom generated exceptions will not extend from PHP built-in Exception class, instead, will extend the \Omega\FaultManager\Abstracts\FaultManagerException abstract class

Warning

In order to use Event Stream everywhere in your app, make sure that you call Fault::enableEventStream() method before calling Fault::throw() / Fault::exception() methods.

Generate Evented Custom Exception

Once the Event Stream is enabled then the process of generating an evented custom exception is the same as with normal custom exceptions shown in “Generate Custom Exception” example.

So since we already have enabled Event Stream in our app, then once we run the following code:

Fault::throw('CustomException', 'a message here');

A file CustomException.php will be generated (in case it does not already exist) with the following contents:

Example 9 CustomException.php (Evented)
<?php

class CustomException extends \Omega\FaultManager\Abstracts\FaultManagerException
{


}

Now you are all set! Time to move to Event Handler !