1. Go to this page and download the library: Download bradleyhodges/api-manager 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/ */
bradleyhodges / api-manager example snippets
use APIManager\APIManager;
// Initialize the APIManager
$apiManager = new APIManager();
use APIManager\APIManager;
// Initialize the APIManager
$apiManager = new APIManager();
// Initialize the HTTP client
$http = $apiManager->useHTTP();
// Send a GET request
$response = $http->get('https://google.com');
// Get the response body
$body = $response->getBody()->getContents();
// Get the response code and reason phrase
$responseCode = $response->getStatusCode(); // 200
$responseReason = $response->getReasonPhrase(); // OK
// More methods and examples at https://docs.guzzlephp.org/en/stable/quickstart.html#using-responses
// Just replace `$client` with `$http` to use them
$http = (new APIManager())->useHTTP();
use APIManager\HTTP;
$http = new HTTP();
$http->useRetry(true)
->useDnsCache(true)
->useHttpVersionFallback(true);
// Send a POST request with a Bearer token
$http->setBearerToken('your-token-here');
$response = $http->post('/submit', ['json' => ['key' => 'value']]);
use APIManager\HTTP;
$http = new HTTP([
// Base URI is used with relative requests
'base_uri' => 'http://httpbin.org',
// You can set any number of default request options.
'timeout' => 2.0,
]);
use APIManager\HTTP;
// Initialize the HTTP client
$http = new HTTP();
// Access the Guzzle client instance
$client = $http->getClient();
// Send an asynchronous request using Guzzle's magic methods:
$promise = $client->getAsync('http://httpbin.org/get');
$responseManager = $apiManager->responseManager();
// Add a message to the response
$responseManager->addMessage('Hello, world!');
// Add an error to the response
$responseManager->addError([
'status' => "422",
'source' => ['pointer' => '/data/attributes/first-name'],
'title' => 'Invalid Attribute',
'detail' => 'First name must contain at least three characters.',
]);
// Respond with data
$responseManager->respond(true, ['some key' => 'some value']); // Successful response
// Respond with an error
$responseManager->respond(false, [], 400); // Error response with optional status code
// Adding a custom header
$apiManager->addHeader('X-Custom-Header', 'CustomValue');
// Removing or preventing a header
$apiManager->removeHeader('X-Frame-Options');
echo $apiManager->sanitizeInput('some input');
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.