PHP code example of codememory / screw

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

    

codememory / screw example snippets


 use Codememory\Screw\HttpRequest;

 $httpRequest = new HttpRequest();
 
 $response = $httpRequest
        ->setUrl('http://example.com/') // Url запроса
        ->setMethod('GET') // Метод запроса
        ->send();

 $httpRequest
    ->setUrl('http://example.com/')
    ->setMethod('GET')
    ->option(HttpRequest::O_REDIRECT, function(RedirectOption $redirect):  RedirectOption {
        $redirect
            ->redirect(true);
        
        return $redirect;
    })
    ->send();

 $httpRequest
    ->setUrl('http://example.com/')
    ->setMethod('GET')
    ->option(HttpRequest::O_REDIRECT, function(RedirectOption $redirect): RedirectOption {
        $redirect
            ->redirect(true)
            ->allowProtocols('http'); 
            
        return $redirect;
    })
    ->option(HttpRequest::TIMEOUT, function(TimeoutOption $timeout): TimeoutOption {
        $timeout
            ->delay(4)
            ->requestTime(5);
         
        return $timeout;
    })
    ->send();