1. Go to this page and download the library: Download initphp/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/ */
initphp / http example snippets
use \InitPHP\HTTP\Message\{Response, Stream};
use \InitPHP\HTTP\Emitter\Emitter;
$response = new Response(200, [], new Stream('Hello World', null), '1.1');
$emitter = new Emitter();
$emitter->emit($response);
use \InitPHP\HTTP\Facade\Factory;
use \InitPHP\HTTP\Facade\Emitter;
$response = Factory::createResponse(200);
$response->getBody()->write('Hello World');
Emitter::emit($response);
use \InitPHP\HTTP\Factory\Factory;
$httpFactory = new Factory();
/** @var \Psr\Http\Message\RequestInterface $request */
$request = $httpFactory->createRequest('GET', 'http://example.com');
// ...
use \InitPHP\HTTP\Message\Request;
use \InitPHP\HTTP\Client\Client;
$request = new Request('GET', 'http://example.com');
$client = new Client();
/** @var \Psr\Http\Message\ResponseInterface $response */
$response = $client->sendRequest($request);
use \InitPHP\HTTP\Facade\Factory;
use \InitPHP\HTTP\Facade\Client;
$request = Factory::createRequest('GET', 'http://example.com');
/** @var \Psr\Http\Message\ResponseInterface $response */
$response = Client::sendRequest($request);
use \InitPHP\HTTP\Stream;
/**
* This content is kept in memory as a variable.
*/
$variableStream = new Stream('String Content', null);
/**
* Content; "php://memory" is overwritten.
*/
$memoryStream = new Stream('Content', 'php://memory');
/**
* Content; "php://temp" is overwritten.
*/
$tempStream = new Stream('Content', 'php://temp');
// or new Stream('Content');
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.