PHP code example of phprise / http-client
1. Go to this page and download the library: Download phprise/http-client 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/ */
phprise / http-client example snippets
use Phprise\Http\Client\NativeClient;
$client = new NativeClient();
$response = $client->sendRequest($request);
echo $response->getStatusCode();
use Phprise\Http\Client\NativeClient;
$client = new NativeClient();
$promise = $client->sendAsyncRequest($request);
$promise->then(
fn($response) => echo "Success: " . $response->getStatusCode(),
fn($exception) => echo "Error: " . $exception->getMessage()
);