Standard API responses for use in Thomas-Institut projects.
This library provides a standard way to structure API responses in PHP projects, ensuring consistency across different services.
You can install the package via Composer:
composer require thomas-institut/standard-apiThe SuccessResponse class represents a successful API operation.
use ThomasInstitut\StandardApi\SuccessResponse;
$response = new SuccessResponse();
// $response->result will be ApiResult::Success
// $response->timeStamp will be set to current timeThe ErrorResponse class represents a failed API operation with a message and an HTTP status code.
use ThomasInstitut\StandardApi\ErrorResponse;
$response = new ErrorResponse('An error occurred', 404);
// $response->result will be ApiResult::Error
// $response->message will be 'An error occurred'
// $response->httpStatus will be 404To run the tests, use the following command:
composer testTo run PHPStan for static analysis:
composer phpstanTo generate a code coverage report (requires Xdebug):
composer test:coverageThis project is licensed under the GPL-3.0-or-later License - see the LICENSE file for details.