PHP code example of nguyenanhung / my-debug

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

    

nguyenanhung / my-debug example snippets



re __DIR__ . '/func.php';

use nguyenanhung\MyDebug\Logger;

// Test Content
$logPath = __DIR__ . '/../tmp';
$logPath = realpath($logPath);
$logSubPath = date('Y-m-d');
$logFilename = 'Log-' . date('Y-m-d') . '.log';
$name = 'Test';
$msg = 'Test Log lan 2';
$context = [
	'name' => 'Nguyen An Hung',
	'email' => '[email protected]',
	'website' => 'https://nguyenanhung.com',
];
// Call
$logger = new Logger();
$logger->setDebugStatus(true);
$logger->setGlobalLoggerLevel();
$logger->setLoggerPath($logPath);
$logger->setLoggerSubPath($logSubPath);
$logger->setLoggerFilename($logFilename);
$logger->__construct();
echo "\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n";
echo "\n getVersion: " . $logger->getVersion() . "\n";
echo "\n setDebugStatus: " . $logger->getDebugStatus() . "\n";
echo "\n setLoggerPath: " . $logger->getLoggerPath() . "\n";
echo "\n setLoggerSubPath: " . $logger->getLoggerSubPath() . "\n";
echo "\n setLoggerFilename: " . $logger->getLoggerFilename() . "\n";
echo "\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n";

__show__($logger->debug($name, $msg . ' - DEBUG', $context));
__show__($logger->info($name, $msg . ' - INFO', $context));
__show__($logger->notice($name, $msg . ' - NOTICE', $context));
__show__($logger->warning($name, $msg . ' - WARNING', $context));
__show__($logger->error($name, $msg . ' - ERROR', $context));
__show__($logger->critical($name, $msg . ' - CRITICAL', $context));
__show__($logger->alert($name, $msg . ' - ALERT', $context));
__show__($logger->emergency($name, $msg . ' - EMERGENCY', $context));


re __DIR__ . '/func.php';

use nguyenanhung\MyDebug\Benchmark;

$benchmark = new Benchmark();
$benchmark->mark('code_start');
$mathFunctions = ["abs", "acos", "asin", "atan", "floor"];
$count = 10;
for ($i = 0; $i < $count; $i++) {
	foreach ($mathFunctions as $key => $function) {
		$function($i);
		echo ($key + 1) . " -> " . $function . "\n";
	}
}
$benchmark->mark('code_end');

__show__($benchmark->elapsed_time('code_start', 'code_end'));
__show__($benchmark->memory_usage());


re __DIR__ . '/func.php';

use nguyenanhung\MyDebug\Manager\File;

$file = new File();
$file->setExclude(array('*.zip'));
$file->setInclude(array('*.log'));

$path = __DIR__ . '/../tmp';
$path = realpath($path);

__show__($file->directoryScanner($path));


re __DIR__ . '/func.php';

use nguyenanhung\MyDebug\Utils;

$utils = new Utils();
$str = 'Nguyễn An Hưng';

__show__($utils->getVersion());
__show__($utils::slugify($str));