PHP code example of sharadkashyap / api-endpoint-diagnostic-tool

1. Go to this page and download the library: Download sharadkashyap/api-endpoint-diagnostic-tool 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/ */

    

sharadkashyap / api-endpoint-diagnostic-tool example snippets




haradKashyap\ApiEndpointDiagnosticTool\Diagnosis\DiagnosisEngine;
use SharadKashyap\ApiEndpointDiagnosticTool\Http\CurlEndpointProbe;
use SharadKashyap\ApiEndpointDiagnosticTool\Http\EndpointRequest;

$request = new EndpointRequest(
    url: 'https://example.com/api/users',
    method: 'POST',
    headers: [
        'Accept: application/json',
        'Content-Type: application/json',
    ],
    body: '{"name":"Sharad"}',
);

$result = (new CurlEndpointProbe())->probe($request);
$report = (new DiagnosisEngine())->diagnose($result);

print_r($report->toArray());
bash
php bin/diagnose.php https://example.com/api/endpoint
bash
php bin/diagnose.php https://example.com/api/endpoint --json