Skip to content

Commit 9bf16de

Browse files
authored
add error handling
1 parent 8603327 commit 9bf16de

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

.env

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
APP_NAME="API-Monster"
1+
APP_NAME="API-Monster"
2+
APP_DEBUG=true

composer.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,8 @@
2929
"homepage": "https://t.me/h3dev",
3030
"role": "Developer"
3131
}
32-
]
33-
}
32+
],
33+
"require": {
34+
"filp/whoops": "^2.15"
35+
}
36+
}

index.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
use Monster\App\Models\Env;
23
use Monster\App\Route;
34

45
/*
@@ -66,6 +67,15 @@
6667
// Autoload dependencies using Composer
6768
require_once 'vendor/autoload.php';
6869

70+
// PHP error handling
71+
$config = new Env('.env');
72+
$debug = $config->get("APP_DEBUG");
73+
if ($debug == "true") {
74+
$whoops = new \Whoops\Run;
75+
$whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler);
76+
$whoops->register();
77+
}
78+
6979
// Load application routes
7080
require 'routes/web.php';
7181

0 commit comments

Comments
 (0)