PHP code example of phprise / http-request

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

    

phprise / http-request example snippets


use Phprise\Http\Request\StoreRequest;
use Phprise\Http\ValueObject\Uri;

$request = new StoreRequest(
    new Uri('https://api.example.com/users'),
    $userDto
);

echo $request->getMethod(); // POST

use Phprise\Http\Request\UpdateRequest;

$request = new UpdateRequest($uri, $patchDto);
echo $request->getMethod(); // PATCH

use Phprise\Http\Request\ListRequest;

$request = new ListRequest($uri);
echo $request->getMethod(); // GET

$request = $request->withHeader('X-Custom', 'Value');