Add initial REST API structure with starter files

This commit is contained in:
MosLaptop\Not.Reda 2025-06-13 13:08:18 +02:00
parent bae0f37414
commit 2c794a113a
2 changed files with 30 additions and 0 deletions

30
Library/Msg.php Normal file
View File

@ -0,0 +1,30 @@
<?php
namespace ppb\Library;
class Msg
{
/**
* Sends either an error or a success message as JSON Object. The error message contains
* additional informations about the error. If no individual msg is given as parameter,
* the default msg will be send
*
* @param boolean $isError is the msg an error msg?
* @param string $msg optional error message
* @param string $ex optional debug message
*/
public function __construct($isError = false, $msg = '', $ex = '')
{
if ($isError) {
$striped = strip_tags($ex);
echo json_encode(array(
"isError" => true,
"msg" => is_null($msg) ? 'Ihre Anfrage konnte nicht verarbeitet werden' : $msg,
"ex" => $striped
));
} else {
echo json_encode(array("isError" => false));
}
die;
}
}