<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
psr-discovery / http-factory-implementations example snippets
use PsrDiscovery\Discover;
// Returns a PSR-17 RequestFactoryInterface instance
$requestFactory = Discover::httpRequestFactory();
// Returns a PSR-17 ResponseFactoryInterface instance
$responseFactory = Discover::httpResponseFactory();
// Returns a PSR-17 StreamFactoryInterface instance
$streamFactory = Discover::httpStreamFactory();
// Returns a PSR-17 UploadedFileFactoryInterface instance
$uploadedFileFactory = Discover::httpUploadedFileFactory();
// Returns a PSR-17 UriFactoryInterface instance
$uriFactory = Discover::httpUriFactory();
// Returns a PSR-7 RequestInterface instance
$request = $requestFactory->createRequest('GET', 'https://example.com');
use PsrDiscovery\Discover;
$requestFactory = Discover::httpRequestFactory();
if ($requestFactory === null) {
// No suitable HTTP RequestFactory implementation was discovered.
// Fall back to a default implementation.
$requestFactory = new DefaultRequestFactory();
}
use PsrDiscovery\Discover;
use PsrDiscovery\Implementations\Psr17\RequestFactories;
// Prefer the a specific implementation of PSR-17 over others.
RequestFactories::prefer('nyholm/psr7');
// Return an instance of Nyholm\Psr7\Factory\Psr17Factory,
// or the next available from the list of candidates,
// Returns null if none are discovered.
$factory = Discover::httpRequestFactory();
use PsrDiscovery\Discover;
use PsrDiscovery\Implementations\Psr17\ResponseFactories;
// Only discover a specific implementation of PSR-17.
ResponseFactories::use('nyholm/psr7');
// Return an instance of Nyholm\Psr7\Factory\Psr17Factory,
// or null if it is not available.
$factory = Discover::httpResponseFactory();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.