PHP code example of nikonm / monolog-mattermost

1. Go to this page and download the library: Download nikonm/monolog-mattermost 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/ */

    

nikonm / monolog-mattermost example snippets




use Monolog\Logger;
use NikonM\Monolog\MattermostWebhookHandler;

$url = 'ssl://mattermost.yourcompany.com:443/hooks/<your-hook-token>';//PORT is Required
$options = [
    'username' => 'logger-user',
    'icon_url' => 'http://icons-for-free.com/icon/download-alien_icon-367307.png'
];

// Create the logger
$logger = new Logger('my_logger');
$logger->pushHandler(new MattermostWebhookHandler($url, $options, Logger::DEBUG));

// You can now use your logger
$logger->info('My logger is now ready');