1. Go to this page and download the library: Download initphp/logger 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/ */
initphp / logger example snippets
use \InitPHP\Logger\Logger;
use \InitPHP\Logger\FileLogger;
$logFile = __DIR__ . '/logfile.log';
$logger = new Logger(new FileLogger(['path' => $logFile]));
use \InitPHP\Logger\Logger;
use \InitPHP\Logger\PDOLogger;
$table = 'logs';
$pdo = new \PDO('mysql:dbname=project;host=localhost', 'root', '');
$logger = new Logger(new PDOLogger(['pdo' => $pdo, 'table' => $table]));
$logger->error('User {user} caused an error.', array('user' => 'muhametsafak'));
// INSERT INTO logs (level, message, date) VALUES ('ERROR', 'User muhametsafak caused an error.', '2022-03-11 13:05:45')
use \InitPHP\Logger\Logger;
use \InitPHP\Logger\PDOLogger;
use \InitPHP\Logger\FileLogger;
$logFile = __DIR__ . '/logfile.log';
$table = 'logs';
$pdo = new \PDO('mysql:dbname=project;host=localhost', 'root', '');
$logger = new Logger(new FileLogger(['path' => $logFile]), new PDOLogger(['pdo' => $pdo, 'table' => $table]));
public function emergency(string $msg, array $context = array()): void;
public function alert(string $msg, array $context = array()): void;
public function critical(string $msg, array $context = array()): void;
public function error(string $msg, array $context = array()): void;
public function warning(string $msg, array $context = array()): void;
public function notice(string $msg, array $context = array()): void;
public function info(string $msg, array $context = array()): void;
public function debug(string $msg, array $context = array()): void;
public function log(string $level, string $msg, array $context = array()): void;
$logger->emergency("Something went wrong");
$logger->error("User {username} caused an error.", ["username" => "john"]);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.