PHP code example of mirkhamidov / yii2-notifications

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

    

mirkhamidov / yii2-notifications example snippets


return [
    'bootstrap' => [
        'queueNotifications',
    ],
    'components' => [
        'queueNotifications' => [
            'class' => \yii\queue\db\Queue::class,
            'as log' => \yii\queue\LogBehavior::class,
            'db' => 'db', // DB connection component or its config
            'tableName' => '{{%queue}}', // Table name
            'channel' => 'notification', // Queue channel key
            'mutex' => \yii\mutex\PgsqlMutex::class, // Mutex that used to sync queries
            'mutexTimeout' => 0,
            'ttr' => 5 * 60, // Max time for anything job handling
            'attempts' => 5, // Max number of attempts
        ],
        'notifications' => [
            'class' => \mirkhamidov\notifications\Notifications::class,
        ],
    ],
    'modules' => [
        'notifications' => [
            'class' => mirkhamidov\notifications\Module::class,
            'queueIn' => 'queueNotifications',
            'providers' => [
                'telegram' => [
                    'class' => \mirkhamidov\notifications\providers\Telegram::class,
                ],
            ],
        ],
    ],
];


'components' => [
    'log' => [
        'targets' => [
            ...
            [
                'class' => 'yii\log\FileTarget',
                'categories' => [
                    'mirkhamidov\notifications\providers\*',
                ],
                'logFile' => '@app/runtime/logs/notification-providers.log',
                'logVars' => [],
                'prefix' => function ($message) {
                    return '';
                }
            ],
        ],
    ],
],