{"id":33991124,"url":"https://github.com/brainstudnl/geolocation","last_synced_at":"2026-06-05T11:31:05.416Z","repository":{"id":62549789,"uuid":"480820105","full_name":"brainstudnl/geolocation","owner":"brainstudnl","description":"Get the geolocation of the request using various methods ","archived":false,"fork":false,"pushed_at":"2023-10-09T17:38:30.000Z","size":51,"stargazers_count":0,"open_issues_count":3,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-02T19:24:49.135Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/brainstudnl.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-04-12T13:21:57.000Z","updated_at":"2022-05-02T07:50:53.000Z","dependencies_parsed_at":"2023-02-16T09:46:30.020Z","dependency_job_id":null,"html_url":"https://github.com/brainstudnl/geolocation","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/brainstudnl/geolocation","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brainstudnl%2Fgeolocation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brainstudnl%2Fgeolocation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brainstudnl%2Fgeolocation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brainstudnl%2Fgeolocation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/brainstudnl","download_url":"https://codeload.github.com/brainstudnl/geolocation/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brainstudnl%2Fgeolocation/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":27701748,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-12-13T02:00:09.769Z","response_time":147,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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-12-13T06:39:06.610Z","updated_at":"2025-12-13T06:39:07.191Z","avatar_url":"https://github.com/brainstudnl.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Laravel Geolocation\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/brainstud/geolocation.svg?style=flat-square)](https://packagist.org/packages/brainstud/geolocation)\n[![GitHub Tests Action Status](https://img.shields.io/github/workflow/status/brainstud/geolocation/run-tests?label=tests)](https://github.com/brainstud/geolocation/actions?query=workflow%3Arun-tests+branch%3Amain)\n[![GitHub Code Style Action Status](https://img.shields.io/github/workflow/status/brainstud/geolocation/Check%20\u0026%20fix%20styling?label=code%20style)](https://github.com/brainstud/geolocation/actions?query=workflow%3A\"Check+%26+fix+styling\"+branch%3Amain)\n[![Total Downloads](https://img.shields.io/packagist/dt/brainstud/geolocation.svg?style=flat-square)](https://packagist.org/packages/brainstud/geolocation)\n\nGet the country \u0026 timezone of the request with the cloudflare country header or fallback to a paid geo-locator API.\n\n```php\n$location = Geolocation::getLocation($request);\n// { countryCode: \"NL\", timeZone: \"Europe/Amsterdam\" }\n````\n\nThe aim of this package prioritize the cloudflare header to keep costs down. Only if that fails an API-call will be done.\nBy this philosophy only minimal info will be available. (country code and timezone)\n\n## Installation\n\nYou can install the package via composer:\n\n```bash\ncomposer require brainstud/geolocation\n```\nYou can publish the config file with:\n\n```bash\nphp artisan vendor:publish --tag=\"geolocation-config\"\n```\n\nThis is the contents of the published config file:\n\n```php\nreturn [\n    'header' =\u003e 'CF-IPCountry', // The cloudflare header that contains the country code\n    'geocoder' =\u003e GeoLocator::IpRegistry, // The geocoder to use if the header is empty\n    'ip-registry' =\u003e [ // Credentials for the ip registry API\n        'base_url' =\u003e env('IP_REGISTRY_URL', 'https://api.ipregistry.co'),\n        'key' =\u003e env('IP_REGISTRY_KEY'),\n    ],\n    'ip-stack' =\u003e [ // Credentials for the ip stack API\n        'base_url' =\u003e env('IP_STACK_URL', 'https://api.ipstack.com'),\n        'key' =\u003e env('IP_STACK_KEY'),\n    ],\n    'cache_ttl' =\u003e DateInterval::createFromDateString('2 months'), // Cache TTL for the geocoder services.\n];\n```\n\n## Supported services\n- [Cloudflare IP geolocation](https://support.cloudflare.com/hc/en-us/articles/200168236-Configuring-Cloudflare-IP-Geolocation)\n- [ipregistry](https://ipregistry.co/)\n- [ipstack](https://ipstack.com)\n\n## Contributing\nYou can add a geocoder by creating a class in the `src/GeoLocators` folder that implements `GeoLocatorContract`.\nThen add it to the `GeoLocator` enum and `GeoLocatorFactory`.\n\n## Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.\n\n## Credits\n\n- [Niek Pijp](https://github.com/niekp)\n- [All Contributors](../../contributors)\n\n## License\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrainstudnl%2Fgeolocation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrainstudnl%2Fgeolocation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrainstudnl%2Fgeolocation/lists"}