palauaandsons/cloudflare-geoip

Cloudflare GeoIP helper with Laravel
4,546 1
Install
composer require palauaandsons/cloudflare-geoip
Latest Version:1.3
Laravel:10 – 13
License:MIT
Last Updated:Jul 3, 2026
Links: GitHub  ·  Packagist
Maintainer: palauaandsons

Cloudflare GeoIp for Laravel.

Get the geographical localtion of visitor based off Cloudflare headers.

[!CAUTION] Make sure Visitor Location & IP Geolocation are enabled in Cloudflare Dashboard.

Installation

composer require palauaandsons/cloudflare-geoip
Configuration

Run the following command to publish configuration. Be sure to modify the configuration file specifically the default location to use if the cloudflare headers are absent.

php artisan vendor:publish --tag=cloudflare-geoip-config
Usage
<?php

namespace App\Http\Controllers;

use PalauaAndSons\CloudflareGeoIp\Facades\GeoIp;
use App\Models\Users;

class RegisterController extends Controller {
    public function __invoke(): User
    {
        $location = GeoIp::getLocation();

        return User::create([
            'register_ip' => $location->ip
        ]);
    }
}
Location Object
\PalauaAndSons\CloudflareGeoIp\Location {
    +ip: "192.182.88.29"
    +city: "New Haven"
    +country: "US"
    +continent: "NA"
    +latitude: 41.31
    +longitude: -72.92
    +postalCode: "06510"
    +region: "Connecticut"
    +regionCode: "CT"
    +timezone: "America/New_York"
    // pseudo fields
    +iso_code: 'US' // same as country
    +isoCode: 'US' // same as country
    +state: 'CT' // same as regionCode
    +state_name: 'Connecticut' // same as region
    +stateName: 'Connecticut' // same as region
    +postal_code: '06510' // same as postal_code
    +lat: '41.31' // same as latitude
    +lon: -72.92 // same as longitude

    +toArray(): array
}

Related Packages

doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database s...

641,106,524 9,700
laravel/framework

The Laravel Framework.

593,882,149 34,959
laravel/tinker

Powerful REPL for the Laravel framework.

502,645,077 7,441
laravel/serializable-closure

Laravel Serializable Closure provides an easy and secure way to serialize closur...

418,291,778 609
nunomaduro/collision

Cli error handling for console/command-line PHP applications.

394,964,158 4,660

Version History

Version Released Laravel License
1.3 ^10.0|^11.0|^12.0|^13.0 MIT
1.2 ^9.0|^10.0|^11.0|^12.0 MIT
1.1.1 ^9.0|^10.0|^11.0 MIT
1.1 ^9.0|^10.0|^11.0 MIT
1.0.0 ^9.0|^10.0 MIT