PHP code example of bulldog / http-factory

1. Go to this page and download the library: Download bulldog/http-factory 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/ */

    

bulldog / http-factory example snippets




ulldog\HttpFactory\FactoryBuilder;
$zendFactory = FactoryBuilder::get('zend');



ulldog\HttpFactory\FactoryBuilder;
$factory = FactoryBuilder::get('zend');
$requestFactory = $factory->requestFactory();
$r = $requestFactory->createRequest('GET', 'http://localhost');



ulldog\HttpFactory\FactoryBuilder;
$factory = FactoryBuilder::get('guzzle');
$requestFactory = $factory->requestFactory();
$r = $requestFactory->createRequest('GET', 'http://localhost');



ulldog\HttpFactory\GuzzleHttpFactory;
$factory = new GuzzleHttpFactory();
$requestFactory = $factory->requestFactory();
$r = $requestFactory->createRequest('GET', 'http://localhost');



ulldog\HttpFactory\FactoryBuilder;
$factory = FactoryBuilder::get('zend');
$responseFactory = $factory->responseFactory();
$r = $responseFactory->createResponse(200, 'OK');



ulldog\HttpFactory\FactoryBuilder;
$factory = FactoryBuilder::get('zend');
$reqFactory = $factory->serverRequestFactory();
$params = ['name' => 'value'];
$r = $reqFactory->createServerRequest('GET', '/', $params);



ulldog\HttpFactory\FactoryBuilder;
$httpFactory = FactoryBuilder::get('zend');
$factory = $httpFactory->streamFactory();
$params = ['name' => 'value'];
$r = $factory->createStream('php://memory');



ulldog\HttpFactory\FactoryBuilder;
$httpFactory = FactoryBuilder::get('zend');

$streamFactory = $httpFactory->streamFactory();
$resource = $streamFactory->createStream('php://temp');

$factory = $httpFactory->uploadedFileFactory();
$params = ['name' => 'value'];
$r = $factory->createUploadedFile(
    $resource,
    1,
    \UPLOAD_ERR_OK,
    'filename.txt',
    'txt'
);



ulldog\HttpFactory\FactoryBuilder;
$httpFactory = FactoryBuilder::get('zend');
$factory = $httpFactory->uriFactory();
$r = $factory->createUri('/');