PHP code example of mjoc1985 / fhr-laravel-client

1. Go to this page and download the library: Download mjoc1985/fhr-laravel-client 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/ */

    

mjoc1985 / fhr-laravel-client example snippets


use Mjoc1985\Fhr\Services\FhrSearchService;
use Carbon\Carbon;

$search = FhrSearchService::make();

$results = $search->searchParking(
    location: 'MAN',
    dateFrom: Carbon::parse('2026-08-01'),
    timeFrom: '10:00',
    dateTo: Carbon::parse('2026-08-08'),
    timeTo: '18:00',
);

$cheapest = $results->getCheapestProduct();

use Mjoc1985\Fhr\Services\FhrInventoryService;

$inventory = FhrInventoryService::make();
$product = $inventory->getParkingProduct(12345);
$lounge  = $inventory->getLoungeProduct(6789);

use Mjoc1985\Fhr\Services\FhrCartService;

$cart = FhrCartService::make();
// build cart, add items, retrieve the FHR-hosted checkout URL, etc.

use Mjoc1985\Fhr\FhrClient;

$client = FhrClient::make();               // production credentials
$sandbox = FhrClient::make(sandbox: true); // sandbox credentials

$response = $client->get('search', ['type' => 'Parking', /* ... */]);

$client  = FhrClient::make(sandbox: $someAppFlag);
$search  = FhrSearchService::make(sandbox: $someAppFlag);

$this->app->bind(FhrClient::class, fn () => FhrClient::make(sandbox: isTestMode()));

use Mjoc1985\Fhr\Contracts\ApiLogger;

class DatabaseApiLogger implements ApiLogger
{
    public function log(/* ... */): void
    {
        // persist however you like
    }
}

// in a service provider
$this->app->bind(ApiLogger::class, DatabaseApiLogger::class);
bash
php artisan vendor:publish --tag=fhr-config