PHP code example of guzzlehttp / test-server

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

    

guzzlehttp / test-server example snippets



use GuzzleHttp\Server\Server;

Server::start();
register_shutdown_function(static function () {
    Server::stop();
});

Server::enqueue([
    new Response(201),
]);

$myHttpClient = MyClient();
$response = $this->makeRequest('GET', Server::$url);
// $response will be 201

$requests = Server::received();
// $request[0] is the one sent by MyClient