PHP code example of dragon-code / notify-exceptions

1. Go to this page and download the library: Download dragon-code/notify-exceptions 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/ */

    

dragon-code / notify-exceptions example snippets


\DragonCode\Notifex\Jobs\ExampleJob::class

\DragonCode\Notifex\Jobs\ExampleJob::class => [
    'host'      => env('EXAMPLE_HOST'), // http://127.0.0.1:8080
    'user'      => env('EXAMPLE_USER'), // 'foo'
    'password'  => env('EXAMPLE_PASS'), // 'bar'
    'other_key' => env('EXAMPLE_OTHER_KEY'), // 12345
],

$host      = $this->getConfig(get_class(), 'host');
$user      = $this->getConfig(get_class(), 'user');
$password  = $this->getConfig(get_class(), 'password');
$other_key = $this->getConfig(get_class(), 'other_key');

// or add `config(string $key)` method:

private function config(string $key)
{
    return $this->getConfig(get_class(), $key);
}

$host      = $this->config('host');
$user      = $this->config('user');
$password  = $this->config('password');
$other_key = $this->config('other_key');

// before
use Illuminate\Contracts\Queue\ShouldQueue;

class ExampleJob implements ShouldQueue {}

// after
use DragonCode\Notifex\Abstracts\JobAbstract;

class ExampleJob extends JobAbstract {}

public function report(Throwable $exception)
{
    parent::report($exception);
    
    if (app()->bound('notifex') && $this->shouldReport($exception)) {
        app('notifex')->send($exception);
    }
}

try {
    $foo = $bar
} catch(\Exception $exception) {
    app('notifex')->send($exception);
}

php artisan vendor:publish --provider="DragonCode\Notifex\ServiceProvider"
bash
php artisan make:job <name>

php artisan notifex:test