Debug
The debug package helps to handle errors and display debugging information to the developer., (*1)
, (*2)
Installation
If you are working on an Asgard project you don't need to install this library as it is already part of the standard libraries., (*3)
composer require asgard/debug 0.*
, (*4)
ErrorHandler
Register an error handler, (*5)
$errorHandler = \Asgard\Debug\ErrorHandler::register();
Ignore PHP errors in a specific directory, (*6)
$errorHandler->ignoreDir('libs/old_legay_package/');
Set the logger, (*7)
$errorHandler->setLogger($logger);
The logger should implement \Psr\Log\LoggerInterface., (*8)
Check if the error handler has a logger, (*9)
$errorHandler->isLogging();
Get the backtrace from an exception, (*10)
$trace = $errorHandler->getBacktraceFromException($e);
To log PHP errors, (*11)
$errorHandler->setLogPHPErrors(true);
Log an exception, (*12)
$errorHandler->logException($e);
Log an error, (*13)
$errorHandler->log($severity, $message, $file, $line, $trace);
Severity should be one of the these., (*14)
Activate/Desactivate debugging, (*15)
$errorHandler->setDebug(true);
$errorHandler->setDebug(false);
If debug is set to true, the error handler will display a debugging page to the user when stumbling upon an error, otherwise it will be hidden., (*16)
, (*17)
Debug
Display the debug screen:, (*18)
\Asgard\Debug\d($var1, $var2, ...);
In an Asgard application, the global function d() is an alias of \Asgard\Debug\d:, (*19)
d($var1, $var2, ...);
Contributing
Please submit all issues and pull requests to the asgardphp/asgard repository., (*20)
License
The Asgard framework is open-sourced software licensed under the MIT license, (*21)