PHP code example of 104corp / support
1. Go to this page and download the library: Download 104corp/support 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/ */
104corp / support example snippets
use Corp104\Support\LoggerTrait;
use Psr\Log\LogLevel;
class MyClass {
use LoggerTrait;
public function doSomething() {
$this->log(LogLevel::INFO, 'I do something');
}
}
// --------------------------------------
$foo = new MyClass();
$foo->doSomething(); // 這裡不會記 log
$logger = new \Monolog\Logger('name');
$foo->setLogger($logger);
$foo->doSomething(); // 這裡會記 log