Flarum\Foundation\Application::inDebugMode PHP Method

inDebugMode() public method

Check if Flarum is in debug mode.
public inDebugMode ( ) : boolean
return boolean
    public function inDebugMode()
    {
        return !$this->isInstalled() || $this->config('debug');
    }

Usage Example

Example #1
0
 public function handle(Exception $e)
 {
     if ($e instanceof JsonApiSerializableInterface) {
         $status = $e->getStatusCode();
         $errors = $e->getErrors();
     } elseif ($e instanceof ValidationException) {
         $status = 422;
         $errors = $e->errors()->toArray();
         $errors = array_map(function ($field, $messages) {
             return ['detail' => implode("\n", $messages), 'source' => ['pointer' => '/data/attributes/' . $field]];
         }, array_keys($errors), $errors);
     } elseif ($e instanceof ModelNotFoundException) {
         $status = 404;
         $errors = [];
     } else {
         $status = 500;
         $error = ['code' => $status, 'title' => 'Internal Server Error'];
         if ($this->app->inDebugMode()) {
             $error['detail'] = (string) $e;
         }
         $errors = [$error];
     }
     $document = new Document();
     $document->setErrors($errors);
     return new JsonApiResponse($document, $status);
 }
All Usage Examples Of Flarum\Foundation\Application::inDebugMode