PHP code example of l2iterative / mock-webserver-ext

1. Go to this page and download the library: Download l2iterative/mock-webserver-ext 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/ */

    

l2iterative / mock-webserver-ext example snippets



$complex_response = new ComplexResponse();
$complex_response
    ->when_path_is('/api/users')
    ->when_method_is('POST')
    ->when_header_is('x-api-key', new RegexMatcher('/^mock/'))
    ->when_header_exists('x-api-version')
    ->when_header_not_exists('x-api-version-old')
    ->when_query_param_is('GET', 'session_uid', new RegexMatcher('/^s/'))
    ->when_query_param_exists('POST', 'image')
    ->when_query_param_not_exists('POST', 'debug')
    ->then(new Response('{"id": 1, "name": "John Doe"}', [], 200));