1. Go to this page and download the library: Download dwenzel/reporter-api library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
dwenzel / reporter-api example snippets
use DWenzel\ReporterApi\Api;
use Psr\Http\Message\ServerRequestInterface;
// Create the API middleware
$reporterApi = new Api();
// Check if the API can handle the request
if ($reporterApi->canHandle($request)) {
// Process the request and get response
$response = $reporterApi->process($request, $handler);
}
use DWenzel\ReporterApi\Api;
$api = new Api();
$reportEndpoint = $api->getReportEndpoint();
// Handle a server request
$response = $reportEndpoint->handle($serverRequest);
use DWenzel\ReporterApi\Schema\ApplicationStatus;
use DWenzel\ReporterApi\Schema\Report;
// Create a new report
$report = new Report();
// Set application status using modern PHP enum
$report->setStatus(ApplicationStatus::OK);
$report->setName('My Application');
$report->setApplicationId(12345);
// Get status information
$status = $report->getStatus(); // Returns ApplicationStatus enum
$statusValue = $status->getValue(); // Returns 'ok'
use DWenzel\ReporterApi\Api;
$api = new Api();
// The default endpoint map can be extended
// Default: ['/api/reporter/v1/application/report' => Report::class]