PHP code example of jeffreyvanrossum / simple-slack-error-channel
1. Go to this page and download the library: Download jeffreyvanrossum/simple-slack-error-channel 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/ */
jeffreyvanrossum / simple-slack-error-channel example snippets
// Make instance
$slackErrorHandler = new Handler('https://hooks.slack.com/services/your_webhook');
// Set the error handler
set_error_handler(function (...$args) use ($slackErrorHandler) {
$slackErrorHandler->handle(...$args);
});
// For catching fatal errors
register_shutdown_function(function () use ($slackErrorHandler) {
$err = error_get_last();
if (is_null($err)) {
return;
}
$slackErrorHandler->handle($err['type'], $err['message'], $err['file'], $err['line']);
});