evolutionphp / exceptions
Simple PHP error handler and logger.
1.3
2024-01-18 16:20 UTC
Requires
- php: >=8.2
- evolutionphp/logger: >=1.1
- symfony/error-handler: >=v7.0.0
This package is auto-updated.
Last update: 2024-05-18 17:01:34 UTC
README
Simple PHP error handler and logger.
Installation
Use Composer to install Logger into your project:
composer require evolutionphp/exceptions
Initialize
- Initialize the Exception class
$exceptions = new \EvolutionPHP\Exceptions\Exceptions();
- Register handler. If it's true, script will display errors in window (good for debugging) otherwise errors will be hidden.
$exceptions->register(true);
Logger
This is optional, you can save logs of errors. For params of logger go to SimpleLogger
$exceptions->add_logger([ 'path' => __DIR__.'/logs/', 'level' => 1 ]);
Call instance
If you already initialize the Exception class, then you can call an instance
$instance = \EvolutionPHP\Exceptions\Exceptions::instance(); //Set status header $instance->set_status_header(500); //Write log message $instance->write_log('error','This is error message'); //Check if script is working under command line if($instance->is_cli()){ echo "You are in command line.\n"; }else{ echo 'Welcome to our site.'; }
Authors
This library was primarily developed by CodeIgniter 3 and modified by Andres M for standalone use.