|
5 | 5 | | Set up 404 handler |
6 | 6 | |-------------------------------------------------------------------------- |
7 | 7 | | |
8 | | -| Create a handler for 404 errors |
| 8 | +| Leaf provides a default 404 page, but you can also create your |
| 9 | +| own 404 handler by calling app()->set404(). Whatever function |
| 10 | +| you set will be called when a 404 error is encountered |
9 | 11 | | |
10 | 12 | */ |
11 | 13 | app()->set404(function () { |
12 | | - response()->json("Resource not found", 404, true); |
| 14 | + response()->json('Resource not found', 404, true); |
13 | 15 | }); |
14 | 16 |
|
15 | 17 | /* |
16 | 18 | |-------------------------------------------------------------------------- |
17 | 19 | | Set up 500 handler |
18 | 20 | |-------------------------------------------------------------------------- |
19 | 21 | | |
20 | | -| Create a handler for error 500 |
| 22 | +| Leaf provides a default 500 page, but you can create your own error |
| 23 | +| 500 handler by calling the setErrorHandler() method. The function |
| 24 | +| you set will be called when a 500 error is encountered |
21 | 25 | | |
22 | 26 | */ |
23 | | -app()->setErrorHandler(function ($e = null) { |
24 | | - if ($e) { |
25 | | - if (app()->config("log.enabled")) { |
26 | | - app()->logger()->error($e); |
27 | | - } |
28 | | - } |
29 | | - |
30 | | - response()->json("An error occured, our team has been notified", 500, true); |
| 27 | +app()->setErrorHandler(function () { |
| 28 | + response()->json('An error occured, our team has been notified', 500, true); |
31 | 29 | }); |
32 | 30 |
|
33 | 31 | /* |
|
39 | 37 | | the controller namespace first. |
40 | 38 | | |
41 | 39 | */ |
42 | | -app()->setNamespace("\App\Controllers"); |
| 40 | +app()->setNamespace('\App\Controllers'); |
43 | 41 |
|
44 | | -// You can break up routes into individual files |
45 | | -require __DIR__ . "/_app.php"; |
| 42 | +/* |
| 43 | +|-------------------------------------------------------------------------- |
| 44 | +| Your application routes |
| 45 | +|-------------------------------------------------------------------------- |
| 46 | +| |
| 47 | +| Leaf MVC automatically loads all files in the routes folder that |
| 48 | +| start with "_". We call these files route partials. An example |
| 49 | +| partial has been created for you. |
| 50 | +| |
| 51 | +| If you want to manually load routes, you can |
| 52 | +| create a file that doesn't start with "_" and manually require |
| 53 | +| it here like so: |
| 54 | +| |
| 55 | +*/ |
| 56 | +// require __DIR__ . '/custom-route.php'; |
0 commit comments