<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
psr-discovery / http-client-implementations example snippets
use PsrDiscovery\Discover;
// Return an instance of the first discovered PSR-18 HTTP Client implementation.
$httpClient = Discover::httpClient();
// Send a request using the discovered HTTP Client.
$httpClient->sendRequest(...);
use PsrDiscovery\Discover;
$httpClient = Discover::httpClient();
if ($httpClient === null) {
// No suitable HTTP Client implementation was discovered.
// Fall back to a default implementation.
$httpClient = new DefaultHttpClient();
}
use PsrDiscovery\Discover;
use PsrDiscovery\Implementations\Psr18\Clients;
// Prefer the a specific implementation of PSR-18 over others.
Clients::prefer('guzzlehttp/guzzle');
// Return an instance of GuzzleHttp\Client,
// or the next available from the list of candidates,
// Returns null if none are discovered.
$client = Discover::httpClient();
use PsrDiscovery\Discover;
use PsrDiscovery\Implementations\Psr18\Clients;
// Only discover a specific implementation of PSR-18.
Clients::use('guzzlehttp/guzzle');
// Return an instance of GuzzleHttp\Client,
// or null if it is not available.
$client = Discover::httpClient();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.