ariarijp/exception-to-slack-attachments

Format PHP Exception to Slack Attachments array for alek13/slack.

0.1.0 2018-03-22 15:18 UTC

This package is auto-updated.

Last update: 2024-10-23 11:56:00 UTC


README

Format PHP Exception to Slack Attachments array for alek13/slack.

Circle CI

Requirements

PHP 5.6+ is required.

Installation

Add these lines to your composer.json.

"require": {
    "ariarijp/exception-to-slack-attachments": "0.1.0"
}

Usage example

<?php

require_once __DIR__ . '/vendor/autoload.php';

use ExceptionToSlackAttachments\ExceptionToSlackAttachments;
use Maknz\Slack;

try {
    throw new \Exception('Something went wrong');
} catch (\Exception $e) {
    $attachments = ExceptionToSlackAttachments::toAttachments($e);

    $client = new Slack\Client('http://your.slack.endpoint');
    $client->to('#general')
        ->attach($attachments)
        ->send();
}

Run above code, then you will receive message like below.

example

License

MIT

Author

ariarijp