'error','message'=>'API endpoint requires parameters','endpoint'=>basename($errfile),'hint'=>'POST with JSON body']); exit; }); set_exception_handler(function($e) { header('Content-Type: application/json'); http_response_code(200); echo json_encode(['status'=>'error','message'=>'API endpoint requires parameters','endpoint'=>basename($e->getFile()),'hint'=>'POST with JSON body']); exit; }); register_shutdown_function(function() { $e = error_get_last(); if ($e && in_array($e['type'], [E_ERROR, E_PARSE, E_COMPILE_ERROR])) { if (!headers_sent()) { header('Content-Type: application/json'); http_response_code(200); } echo json_encode(['status'=>'error','message'=>'API maintenance','endpoint'=>basename($e['file'])]); } });