1. Go to this page and download the library: Download lichtner/laravel-mock-api 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/ */
lichtner / laravel-mock-api example snippets
namespace App;
use Illuminate\Http\Client\Response;
use Illuminate\Support\Facades\Http;
use Lichtner\MockApi\MockApi;
class HttpMock
{
public static function get($url): Response
{
MockApi::init($url);
$response = Http::get($url);
MockApi::log($url, $response);
return $response;
}
}
Http::get($url);
HttpMock::get($url);
class HttpMock
{
/* ... here is function get() */
public static function post(string $url, array $data): Response
{
MockApi::init($url, $data, 'POST');
$response = Http::post($url, $data);
MockApi::log($url, $response, 'POST');
return $response;
}
}