rework structure
added Router added .htaccess removed API-Module => is not used renamed batch to CRON
This commit is contained in:
parent
ccf2f506f0
commit
c33bb4cb3a
37 changed files with 680 additions and 190 deletions
48
src/Venom/Exceptions/ExceptionHandler.php
Normal file
48
src/Venom/Exceptions/ExceptionHandler.php
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
<?php
|
||||
|
||||
|
||||
namespace Venom\Exceptions;
|
||||
|
||||
|
||||
use Exception;
|
||||
use Throwable;
|
||||
|
||||
class ExceptionHandler
|
||||
{
|
||||
private string $logFile = __DIR__ . '/../../../logs/Exception.log';
|
||||
private $file;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
try {
|
||||
$this->file = fopen($this->logFile, 'ab+');
|
||||
} catch (Throwable $ex) {
|
||||
$this->file = null;
|
||||
}
|
||||
}
|
||||
|
||||
public static function setExceptionHandler(): void
|
||||
{
|
||||
set_exception_handler(array(__CLASS__, 'handleException'));
|
||||
}
|
||||
|
||||
public static function handleException(Throwable $ex): void
|
||||
{
|
||||
$handler = new ExceptionHandler();
|
||||
$handler->writeException($ex);
|
||||
exit(255);
|
||||
}
|
||||
|
||||
public function writeException(Throwable $ex): void
|
||||
{
|
||||
if ($this->file !== null) {
|
||||
try {
|
||||
$trace = "=====[FATAL ERROR]=====\n" . $ex->getMessage() . "\n" . $ex->getTraceAsString() . "\n=====[FATAL ERROR END]=====\n";
|
||||
fwrite($this->file, $trace);
|
||||
fclose($this->file);
|
||||
} catch (Exception $e) {
|
||||
trigger_error("cannot write Exception file!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue