use rafalmasiarek\DashboardKitGeoIp\GeoIpAddon;
use rafalmasiarek\DashboardKitGeoIp\GeoIpDriverInterface;
use rafalmasiarek\DashboardKitGeoIp\GeoIpResult;
final class MyDriver implements GeoIpDriverInterface
{
public function resolve(string $ip): GeoIpResult
{
// never throw — return empty GeoIpResult on any failure
return new GeoIpResult(
country: 'Poland',
countryCode: 'PL',
city: 'Warsaw',
region: 'Masovian Voivodeship',
);
}
}
$container->set(GeoIpDriverInterface::class, fn() => new MyDriver());
GeoIpAddon::register($dashboard->getApp(), $container);
final class IpApiDriver implements GeoIpDriverInterface
{
public function __construct(
private readonly string $url = 'http://ip-api.com/json/%s?fields=country,countryCode,city,regionName',
private readonly int $timeoutMs = 3000,
) {}
public function resolve(string $ip): GeoIpResult { ... }
}
// point at CF Worker for retries and HTTPS:
$container->set(GeoIpDriverInterface::class, fn() => new IpApiDriver(
url: 'https://geoip.example.workers.dev/%s',
));
use Monolog\Formatter\JsonFormatter;
$container->set('geoip.log.formatter', fn() => new JsonFormatter());
GeoIpAddon::register($dashboard->getApp(), $container);
'geoip' => [
'db_path' => '/path/to/GeoLite2-City.mmdb', // retention in days
],
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.