PHP code example of understeam / yii2-slack

1. Go to this page and download the library: Download understeam/yii2-slack 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/ */

    

understeam / yii2-slack example snippets


...
    'components' => [
        'httpclient' => [
            'class' => 'yii\httpclient\Client',
        ],
    ],
...

...
    'components' => [
        'slack' => [
            'httpclient' => [
                'class' => 'yii\httpclient\Client',
            ],
            ...
        ],
    ],
...

...
    'components' => [
        'slack' => [
            'class' => 'understeam\slack\Client',
            'url' => '<slack incoming webhook url here>',
            'username' => 'My awesome application',
        ],
    ],
...

Yii::$app->slack->send('Hello', ':thumbs_up:', [
    [
        // attachment object
        'text' => 'text of attachment',
        'pretext' => 'pretext here',
    ],
]);

...
'components' => [
    'log' => [
        'traceLevel' => 3,
        'targets' => [
            [
                'class' => 'understeam\slack\LogTarget',
                'categories' => ['commandBus'],
                'exportInterval' => 1, // Send logs on every message
                'logVars' => [],
            ],
        ],
    ],
],
...
bash
php composer.phar