{"id":28178538,"url":"https://github.com/movemoveapp/laravel-maxmind","last_synced_at":"2026-03-09T22:03:11.587Z","repository":{"id":293428529,"uuid":"983468450","full_name":"movemoveapp/laravel-maxmind","owner":"movemoveapp","description":"A Laravel package for reading MaxMind GeoIP2 data passed from Nginx via FastCGI parameters. Supports automatic detection of location and ISP information using predefined headers, with full configuration support.","archived":false,"fork":false,"pushed_at":"2025-05-15T15:44:40.000Z","size":11,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-17T11:15:34.441Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/movemoveapp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-05-14T12:30:51.000Z","updated_at":"2025-05-15T15:40:23.000Z","dependencies_parsed_at":"2025-05-15T09:51:18.621Z","dependency_job_id":null,"html_url":"https://github.com/movemoveapp/laravel-maxmind","commit_stats":null,"previous_names":["movemoveapp/laravel-maxmind"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/movemoveapp/laravel-maxmind","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/movemoveapp%2Flaravel-maxmind","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/movemoveapp%2Flaravel-maxmind/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/movemoveapp%2Flaravel-maxmind/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/movemoveapp%2Flaravel-maxmind/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/movemoveapp","download_url":"https://codeload.github.com/movemoveapp/laravel-maxmind/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/movemoveapp%2Flaravel-maxmind/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30314406,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-09T20:05:46.299Z","status":"ssl_error","status_checked_at":"2026-03-09T19:57:04.425Z","response_time":61,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-05-16T01:12:40.096Z","updated_at":"2026-03-09T22:03:11.570Z","avatar_url":"https://github.com/movemoveapp.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🌍 Laravel MaxMind\n[![Latest Stable Version](http://poser.pugx.org/movemoveapp/laravel-maxmind/v)](https://packagist.org/packages/movemoveapp/laravel-maxmind)\n[![Total Downloads](http://poser.pugx.org/movemoveapp/laravel-maxmind/downloads)](https://packagist.org/packages/movemoveapp/laravel-maxmind)\n[![Latest Unstable Version](http://poser.pugx.org/movemoveapp/laravel-maxmind/v/unstable)](https://packagist.org/packages/movemoveapp/laravel-maxmind)\n[![License](http://poser.pugx.org/movemoveapp/laravel-maxmind/license)](https://packagist.org/packages/movemoveapp/laravel-maxmind)\n[![PHP Version Require](http://poser.pugx.org/movemoveapp/laravel-maxmind/require/php)](https://packagist.org/packages/movemoveapp/laravel-maxmind)\n\n**Laravel MaxMind** is a simple and flexible package for accessing [MaxMind GeoIP2](https://maxmind.com/) data passed via Nginx FastCGI parameters.\n\nIt allows your Laravel application to read geolocation and ISP information that is resolved by Nginx using the GeoIP2 module, without querying MaxMind databases directly from PHP.\n\n---\n\n## Features\n\n- Automatically parses FastCGI parameters set by Nginx with MaxMind GeoIP2 data\n- Supports continent, country, region, city, postal, connection, and ISP data\n- Configuration file to override default parameter names\n- No need to access MaxMind database from PHP – uses data injected by Nginx\n\n---\n\n## Requirements\n\n- Laravel 10+\n- Nginx with `ngx_http_geoip2_module`\n- MaxMind `.mmdb` database files\n- FastCGI configuration passing GeoIP data to PHP\n\n---\n\n## Installation\n\n```bash\ncomposer require movemoveapp/laravel-maxmind\n```\n\n## Register the Service Provider\nAfter installing the package, you need to register the MaxMind service provider.\n\n### Laravel 10 and below\n\nAdd the following line to the providers array in your `config/app.php` file:\n\n```php\n...\n'providers' =\u003e [\n    // Other providers...\n    MoveMoveApp\\Maxmind\\MaxmindServiceProvider::class,\n],\n\n```\n\n### Laravel 11 and above\n\nRegister the service provider in the `bootstrap/providers.php` file:\n\n```php\n\u003c?php\n\n\u003c?php\n\nreturn [\n    // Other providers...\n    MoveMoveApp\\Maxmind\\MaxmindServiceProvider::class,\n];\n\n\n```\n\n## Publish the Configuration\n\nTo publish the configuration file and customize the package settings, run the following Artisan command:\n\n```shell\nphp artisan vendor:publish --provider='MoveMoveApp\\Maxmind\\MaxmindServiceProvider'\n```\n\n# Configuration\n\nOnce published, the configuration file will be available at `config/maxmind.php`.\n\nThis file maps MaxMind geolocation headers to internal configuration keys. You may override the defaults using your `.env` file. Below are the available environment variables and their default values:\n\n```php\n...\n## Maxmind\nMAXMIND_ISP_AS_ORGANIZATION=X-ISP-AS-Organization\nMAXMIND_ISP_AS=X-ISP-AS\nMAXMIND_ISP_ORGANIZATION=X-ISP-Organization\nMAXMIND_ISP_NAME=X-ISP-Name\nMAXMIND_CONNECTION_TYPE=X-Connection-Type\nMAXMIND_POSTAL_CONFIDENCE=X-Postal-Confidence\nMAXMIND_POSTAL_CODE=X-Postal-Code\nMAXMIND_METRO_CODE=X-Metro-Code\nMAXMIND_TIME_ZONE=X-Time-Zone\nMAXMIND_LONGITUDE=X-Longitude\nMAXMIND_LATITUDE=X-Latitude\nMAXMIND_AVERAGE_INCOME=X-Average-Income\nMAXMIND_ACCURACY_RADIUS=X-Accuracy-Radius\nMAXMIND_CITY_CODE=X-City-Code\nMAXMIND_CITY_NAME=X-City-Name\nMAXMIND_REGION_CODE=X-Region-Code\nMAXMIND_REGION_ISO=X-Region-Iso\nMAXMIND_REGION_NAME=X-Region-Name\nMAXMIND_COUNTRY_CODE=X-Country-Code\nMAXMIND_COUNTRY_ISO=X-Country-Iso\nMAXMIND_COUNTRY_NAME=X-Country-Name\nMAXMIND_CONTINENT_CODE=X-Continent-Code\nMAXMIND_CONTINENT_ISO=X-Continent-Iso\nMAXMIND_CONTINENT_NAME=X-Continent-Name\n\n...\n```\n\nEach configuration key corresponds to a header (typically set via a reverse proxy or edge server like Nginx). You can override any of these defaults by defining the respective environment variable in your `.env` file.\n\n## Nginx Configuration\nTo ensure that the MaxMind headers are correctly passed to your Laravel application, you need to configure your Nginx (or other reverse proxy) to forward the appropriate HTTP headers. These headers typically come from services like MaxMind's GeoIP2 or your CDN (e.g., Cloudflare, Fastly, or your own proxy setup).\n\nBelow is a sample Nginx configuration that sets the headers based on your upstream data (e.g., using `geoip2` module or an external resolver):\n\n### Step 1: Enable GeoIP2 in `nginx.conf`\n\nYou must configure the `ngx_http_geoip2_module` to extract the relevant fields from your MaxMind `.mmdb` files:\n\n```apacheconf\ngeoip2 /usr/share/GeoIP/GeoIP2-City.mmdb {\n    $geoip2_continent_name continent names en;\n    $geoip2_continent_iso continent code;\n    $geoip2_continent_code continent geoname_id;\n\n    $geoip2_country_name country names en;\n    $geoip2_country_iso country iso_code;\n    $geoip2_country_code country geoname_id;\n\n    $geoip2_region_name subdivisions names en;\n    $geoip2_region_iso subdivisions iso_code;\n    $geoip2_region_code subdivisions geoname_id;\n\n    $geoip2_city_name city names en;\n    $geoip2_city_code city geoname_id;\n\n    $geoip2_accuracy_radius location accuracy_radius;\n    $geoip2_average_income location average_income;\n    $geoip2_latitude location latitude;\n    $geoip2_longitude location longitude;\n    $geoip2_time_zone location time_zone;\n    $geoip2_metro_code location metro_code;\n    $geoip2_population_density location population_density;\n    $geoip2_postal_code postal code;\n    $geoip2_postal_confidence postal confidence;\n}\n\ngeoip2 /usr/share/GeoIP/GeoIP2-Connection-Type.mmdb {\n    $geoip2_connection_type connection_type;\n}\n\ngeoip2 /usr/share/GeoIP/GeoIP2-ISP.mmdb {\n    $geoip2_isp_name isp;\n    $geoip2_isp_organization organization;\n    $geoip2_as autonomous_system_number;\n    $geoip2_as_organization autonomous_system_organization;\n}\n\n```\n\n### Step 2: Pass GeoIP2 Data via `fastcgi_param`\n\nIn your site configuration (typically under `sites-available/your-site.conf`), include the following `fastcgi_param` directives in the `location ~ \\.php$` block to pass GeoIP2 values to PHP:\n\n```apacheconf\nfastcgi_param X-Continent-Name         $geoip2_continent_name;\nfastcgi_param X-Continent-Iso          $geoip2_continent_iso;\nfastcgi_param X-Continent-Code         $geoip2_continent_code;\n\nfastcgi_param X-Country-Name           $geoip2_country_name;\nfastcgi_param X-Country-Iso            $geoip2_country_iso;\nfastcgi_param X-Country-Code           $geoip2_country_code;\n\nfastcgi_param X-Region-Name            $geoip2_region_name;\nfastcgi_param X-Region-Iso             $geoip2_region_iso;\nfastcgi_param X-Region-Code            $geoip2_region_code;\n\nfastcgi_param X-City-Name              $geoip2_city_name;\nfastcgi_param X-City-Code              $geoip2_city_code;\n\nfastcgi_param X-Accuracy-Radius        $geoip2_accuracy_radius;\nfastcgi_param X-Average-Income         $geoip2_average_income;\nfastcgi_param X-Latitude               $geoip2_latitude;\nfastcgi_param X-Longitude              $geoip2_longitude;\nfastcgi_param X-Time-Zone              $geoip2_time_zone;\nfastcgi_param X-Metro-Code             $geoip2_metro_code;\nfastcgi_param X-Postal-Density         $geoip2_population_density;\nfastcgi_param X-Postal-Code            $geoip2_postal_code;\nfastcgi_param X-Postal-Confidence      $geoip2_postal_confidence;\n\nfastcgi_param X-Connection-Type        $geoip2_connection_type;\n\nfastcgi_param X-ISP-Name               $geoip2_isp_name;\nfastcgi_param X-ISP-Organization       $geoip2_isp_organization;\nfastcgi_param X-ISP-AS-Number          $geoip2_as;\nfastcgi_param X-ISP-AS-Organization    $geoip2_as_organization;\n\n```\n\n⚠️ These parameters will be available in Laravel using $request-\u003eserver('HTTP_X_CONTINENT_NAME'), etc. The package automatically maps them internally — you don't need to manually extract them in your controller.\n\n### Verifying Integration\n\nTo verify that your headers are being received:\n\n1. Run php artisan `route:clear` to refresh routing cache.\n2. Create a debug route:\n\n```php\nRoute::get('/debug-geo', function (\\Illuminate\\Http\\Request $request) {\n    return request()-\u003eserver();\n});\n\n```\n\n3. Access `/debug-geo` in your browser and check for `HTTP_X_CONTINENT_NAME`, `HTTP_X_COUNTRY_NAME`, etc.\n\n\n## Helpers\n\n### Detect IP type\n\nThen you can use the detectIpType function like this:\n\n```php\nuse MoveMoveApp\\Maxmind\\Enums\\NetworkType;\n\n...\n\n$ip = '2001:0db8:85a3::8a2e:0370:7334';\n\n$type = detectIpType($ip);\n\nif ($type === NetworkType::IPV6) {\n    echo \"IPv6 address detected.\";\n} elseif ($type === NetworkType::IPV4) {\n    echo \"IPv4 address detected.\";\n} else {\n    echo \"Invalid IP address.\";\n}\n\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmovemoveapp%2Flaravel-maxmind","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmovemoveapp%2Flaravel-maxmind","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmovemoveapp%2Flaravel-maxmind/lists"}