PHP code example of juliangut / spiral

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

    

juliangut / spiral example snippets




use Jgut\Spiral\Client;

// Create Spiral cURL client
$spiralClient = new Client;

// Create \Psr\Http\Message\RequestInterface request and configure it
$request = new PSR7RequestImplementation();

// Perform the request providing an empty \Psr\Http\Message\ResponseInterface response object to be populated
$response = $spiralClient->request($request, new PSR7ResponseImplementation());

// Use response
$headers = $response->getHeaders();
$content = (string) $response->getBody();

$transport = new Curl;

$spiralClient = new Client($transport);

$transport = Curl::createFromDefaults();

$spiralClient = new Client($transport);

use Jgut\Spiral\Transport\Curl;
use Jgut\Spiral\Option\ConnectTimeout;

// Create Spiral cURL client
$transport = new Curl;

// Set option explicitly
$transport->setOption(new ConnectTimeout(10));

// Set by cURL constant
$transport->setOption(CURLOPT_CONNECTTIMEOUT, 10);

// Set using an alias
$transport->setOption('connect_timeout', 10);