PHP code example of m1lt0n / dialog

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

    

m1lt0n / dialog example snippets




// Pick the Engine (i.e. template/placeholder matcher, usually the Psr3Engine
// provided with the package will suffice)
$engine = new \Dialog\Message\Psr3Engine(new \Dialog\Message\ExceptionStringFormatter());

// Get a new HandlerBag to add Handlers for the log messages
// This allows us to have several handlers and upon triggering log or any
// log-level specific method, all of the handlers will do their job independently
// (e.g. one may write on the screen, another in a file etc)
$handlerBag = new \Dialog\Log\HandlerBag();

// Instantiate the Logger (this one is provided and is quite generic, so you can
// use it out of the box!
$logger = new \Dialog\Log\Logger($engine, $handlerBag);

// Formatters, well, format the log line (e.g. creen1', $handler1);

//----------------

// this message will be displayed
$logger->log(\Dialog\Log\LogLevel::WARNING, 'test');

// this one will not as the threshold condition is not met
$logger->log(\Dialog\Log\LogLevel::INFO, 'test');