1. Go to this page and download the library: Download pinkcrab/http 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/ */
pinkcrab / http example snippets
use PinkCrab\HTTP\HTTP;
use PinkCrab\HTTP\HTTP;
$http = new HTTP();
$response = $http->wp_response(
['some_key'=>'some_value'],
200,
['Content-Type' => 'application/json; charset=UTF-8']
);
// OR
$response = HTTP_Helper::wp_response(
['some_key'=>'some_value'],
200,
['Content-Type' => 'application/json; charset=UTF-8']
);
// Emit to client
$http->emit_response($response);
use PinkCrab\HTTP\HTTP;
use PinkCrab\HTTP\HTTP;
$http = new HTTP();
$response = $http->ps7_response(
['some_key'=>'some_value'],
200,
['Content-Type' => 'application/json; charset=UTF-8']
);
// OR
$response = HTTP_Helper::response(
['some_key'=>'some_value'],
200,
['Content-Type' => 'application/json; charset=UTF-8']
);
// Emit to client
$http->emit_response($response);
use PinkCrab\HTTP\HTTP;
use PinkCrab\HTTP\HTTP_Helper;
$http = new HTTP();
$request = $http->psr7_request(
'GET',
'https://google.com'
);
// OR
$request = HTTP_Helper::request(
'GET',
'https://google.com'
);
use PinkCrab\HTTP\HTTP;
use PinkCrab\HTTP\HTTP_Helper;
$server = (new HTTP())->request_from_globals();
// OR
$server = HTTP_Helper::global_server_request();
use PinkCrab\HTTP\HTTP;
use PinkCrab\HTTP\HTTP_Helper;
$stream = (new HTTP())->stream_from_scalar($data);
// OR
$stream = HTTP_Helper::stream_from_scalar($data);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.