PHP code example of overtrue / cuttle

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

    

overtrue / cuttle example snippets


use Overtrue\Cuttle\Cuttle;

$config = [
    'default' => 'foo', // default channel
        
    'formatters' => [
        'dashed' => [
            'formatter' => \Monolog\Formatter\LineFormatter::class, // default
            'format' => "%datetime% - %channel%.%level_name% - %message%\n" 
        ],
    ],
    'handlers' => [
        'file' => [
            'handler' => \Monolog\Handler\StreamHandler::class,  // default
            'formatter' => 'dashed',
            'stream' => '/tmp/demo.log',
            'level' => 'info',
        ],
        'console' => [
            'formatter' => 'dashed',
            'stream' => 'php://stdout',
            'level' => 'debug',
        ],
    ],
    'channels' => [
        'foo' => [
            'handlers' => ['console', 'file'],
        ],
        'bar' => [
            'handlers' => ['file'], 
        ],
    ],
];

$cuttle = new Cuttle($config);

$cuttle->info('hello'); // channel: foo
$cuttle->channel('bar')->debug('debug message.');

// aslias of channel($name)
// ->of('bar')
// ->from('bar')