PHP Classes

File: infrastructure/helpers/Handlers.php

Recommend this page to a friend!
  Classes of Maicon gonçalez   Potato Service   infrastructure/helpers/Handlers.php   Download  
File: infrastructure/helpers/Handlers.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Potato Service
Framework that extracts route details from classes
Author: By
Last change: feat(filter): implement doFilter function
feat(core): remove repository, fix small bugs, started console cli
Date: 9 months ago
Size: 1,006 bytes
 

Contents

Class file image Download
<?php

function handler_exception($Execption): void {
    if (
PHP_SAPI === 'cli'){
        echo
"Error Code: ".$Execption->getCode()."\n";
        echo
"Error Message: ".$Execption->getMessage();
    }else{
       
response()->setHeaderType(\infrastructure\core\enums\ContentType::CONTENT_JSON);
        echo
json_encode([
           
"timestamp" => time(),
           
"exception" => get_class($Execption),
           
"status" => $Execption->getCode(),
           
"path" => request()->requestUri,
           
"message" => $Execption->getMessage(),
           
"error" => isset($Execption->error_message) ? _($Execption->error_message) : _("Exception")
        ]);
       
http_response_code((int)$Execption->getCode());
    }
    exit();
}

function
registerAutoloads($class): void {
   
$filename = ROOT_PATH . DIRECTORY_SEPARATOR . str_replace('\\', '/', $class) . '.php';

   
$filename = str_replace("//", "/", $filename);

    if (
file_exists($filename)) {
        require_once(
$filename);
    }
}