This is a simple package that allow a PHP script to send real time logs to Slack.
Please be aware that the repository is still in an early phase, and every new commit might not be backward compatible.
Installation of Slack Logger is done using Composer.
composer require mathieuimbert/slack-logger
- Create an Incoming Webhook for your slack account. Make sure to read the full documentation
- Instantiate SlackLogger in your script, and start sending logs to Slack
$logger = new \MathieuImbert\Slack\Logger\SlackLogger('https://hooks.slack.com/services/xxxxxxx/xxxxxxx/xxxxxxx');
$logger->warning('This a not test of the emergency broadcast system, this is the real thing');
You can customize the name and the icon of your logger in the incoming webhook configuration, or you can do it from SlackLogger by passing the right options to he constructor:
$logger = new \MathieuImbert\SlackLogger\SlackLogger(
'https://hooks.slack.com/services/xxxxxxx/xxxxxxx/xxxxxxx',
array('username' => 'My Slack Logger', 'icon_emoji' => ':cop:')
);