PHP code example of walkboy / yii2-slack

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

    

walkboy / yii2-slack example snippets


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

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

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

Yii::$app->slack->send('Hello', ':thumbs_up:', [
    // block object 1
    [
        'type' => 'context',
        'elements' => [
            [
                'type' => 'mrkdwn',
                'text' => 'Your markdown text here',
            ]
        ],
    ],
    // block object 2
    [
        'type' => 'divider',
    ]
]);

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