1. Go to this page and download the library: Download oji3t/e2slack 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/ */
oji3t / e2slack example snippets
use ExceptionToSlack\Notification;
use FooException;
try {
throw new FooException;
} catch (FooException $e) {
$config = ['endpoint' => YOUR_WEBHOOK_ENDPOINT];
$notification = new Notification($e, $config);
$notification->send();
}
use FooException;
try {
throw new FooException;
} catch (FooException $e) {
$config = ['endpoint' => YOUR_WEBHOOK_ENDPOINT];
e2slack($e, $config);
}
use ExceptionToSlack\Notification;
use FooException;
try {
throw new FooException;
} catch (FooException $e) {
$config = ['endpoint' => YOUR_WEBHOOK_ENDPOINT];
$notification = new Notification($e, $config);
$notification->setUsername('Debug Bot');
$notification->setChannel('@user.name');
$notification->setIcon(':love_letter:');
$notification->send();
}
// app/Exceptions/Handler.php
namespace App\Exceptions;
use Exception;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Illuminate\Http\Response;
use App\Exceptions\FooException;
use ExceptionToSlack\Notification;
class Handler extends ExceptionHandler
{
// ~~~
public function render($request, Exception $e)
{
if ($e instanceof FooException) {
$notification = new Notification($e, config('services.e2slack'));
$notification->send();
}
return parent::render($request, $e);
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.