1. Go to this page and download the library: Download flerex/spain-gas 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/ */
flerex / spain-gas example snippets
use Flerex\SpainGas\Enums\Fuel;
use Flerex\SpainGas\GasApi;
$stations = GasApi::gasStations()
->fuel(Fuel::CNG())
->get();
use Flerex\SpainGas\Dtos\Town;
use Flerex\SpainGas\Enums\Province;
use Flerex\SpainGas\GasApi;
$towns = GasApi::towns()
->province(Province::A_CORUNHA())
->get();
$townId = array_filter($towns, fn(Town $town) => stripos($town->name, 'Coruña') !== false)[0];
// Everything up to this point could be done once and then be replaced with the obtained ID to avoid unnecessary API calls.
$stations = GasApi::gasStations()
->town($townId)
->get();
use Flerex\SpainGas\Dtos\GasStationLocation;
use Flerex\SpainGas\Enums\Rank;
use Flerex\SpainGas\Enums\Fuel;
use Flerex\SpainGas\Enums\ServiceType;
use Flerex\SpainGas\GasApi;
$stations = GasApi::locateGasStations()
->serviceType(ServiceType::SELF_SERVICE())
->fuel(Fuel::DIESEL_A())
->get();
$cheapest = array_filter($stations, fn(GasStationLocation $station) => $station->rank->equals(Rank::CHEAP()));
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.