PHP code example of eg-mohamed / laravel-http-client-cache
1. Go to this page and download the library: Download eg-mohamed/laravel-http-client-cache 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/ */
eg-mohamed / laravel-http-client-cache example snippets
use Illuminate\Support\Facades\Http;
$response = Http::cache('products-api', 600)
->get('https://api.example.com/products');
$response->fromCache(); // false on the first call, true on subsequent calls
$response = Http::cache('weather-today', 600)
->get('https://api.example.com/weather');
$response->fromCache(); // bool
$response->json(); // works exactly like a normal response