Download the PHP package atldays/laravel-geo without Composer

On this page you can find all versions of the php package atldays/laravel-geo. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-geo

Laravel Geo

Latest Version on Packagist Total Downloads CI Live

atldays/laravel-geo retrieves visitor location from IP addresses using both online and local services. No matter which provider is used, the result is normalized geo data such as country, city, continent, and coordinates.

You can use it directly from the current request, from any Request instance, or from an explicit IP address.

All supported drivers are normalized into the same strongly typed GeoContract, so you work with consistent DTOs instead of provider-specific arrays.

Drivers

The package includes these drivers out of the box:

The default driver is IpApi, because it lets developers install the package and see real results immediately.

Installation

Publish the config file if you want to customize driver order or provider settings:

Quick Start

Current request geo data

Use the Geo facade when you want data for the current request.

Available facade methods match GeoContract:

Explicit IP and request lookups

Use the GeoManager facade when you want to resolve a specific IP or request instance.

GeoManager::ip() and GeoManager::request() return Atldays\Geo\Contracts\GeoContract.

Dependency Injection

You can also resolve the current geo result through dependency injection using GeoContract.

Configuration

The main config file is config/geo.php.

Default driver and fallbacks

You can switch to MaxMind and keep IpApi as a fallback:

Drivers are resolved in this order:

  1. geo.driver
  2. every class from geo.fallbacks

If a driver throws DriverUnavailableException, the manager moves to the next configured driver.

Request Macros

The package registers three request macros:

GeoManager::request() uses:

  1. fakeIp() when debug mode is enabled and a valid fake IP is present
  2. otherwise realIp()

The fake IP input key is configurable:

That makes local testing convenient:

You can also resolve geo data directly from any Request instance:

IP-API

IP-API is the default driver because it gives immediate feedback after installation.

You do not need to create credentials or download a local database to start using it.

If you install the package and keep the default configuration, Geo and GeoManager will already resolve data through IpApi.

Example:

Config:

This is the recommended choice when you want to try the package quickly without creating external credentials or downloading a local database first.

MaxMind

MaxMind uses a local .mmdb database and is the better choice when you want stable local lookups backed by a real database file.

To use it, you need a MaxMind account and credentials for the GeoLite2 download service.

GeoLite2 is free, so developers can start with the free MaxMind offering and still get a solid local integration.

Config:

MaxMind setup flow

  1. Create or sign in to your MaxMind account.
  2. Generate a license key for GeoLite2 downloads.
  3. Add MAXMIND_ACCOUNT_ID and MAXMIND_LICENSE_KEY to your environment.
  4. Switch your geo.driver to MaxMind::class if you want it as the primary driver.
  5. Run the update command to download the local database.

Example environment:

Updating the MaxMind database

Run:

Force a fresh download even if the local file appears current:

The updater stores:

UpdateResult is generic and only reports:

Source-specific details such as edition_id, download_url, or remote_last_modified live inside metadata instead of the shared DTO.

Geo Data

Resolved geo data is normalized into GeoContract.

That means driver-specific payloads are not exposed as arbitrary top-level structures. Every supported driver is mapped into the same typed result shape.

Depending on the driver and available source data, you may receive:

Nested geo objects are normalized too:

provider() returns the driver name that produced the result, such as MaxMind or IpApi.

externalId is provider-specific metadata. For MaxMind, it maps to geoname_id. For IpApi, it is null. It should not be treated as a globally stable cross-provider identifier.

country()->definition() resolves rich country metadata through the configured country definition provider.

By default the package points to Atldays\Geo\CountryDefinitions\Rinvex, which requires the optional rinvex/countries package to be installed.

Install it when you want to use country definitions:

Config:

The configured provider is resolved through CountryDefinitionManager, so additional providers can be added later without changing the CountryContract API.

Example:

If the configured provider depends on an optional package that is not installed, the package throws DefinitionUnavailable.

Some drivers may return partial data. A lookup can still be successful even if only part of the geo payload is available.

Public API

Main public package entry points:

Testing

Run the standard test suite:

Run formatting checks:

Run live driver checks:

Live tests cover real providers and may require external credentials, especially for MaxMind.

License

The MIT License (MIT). Please see LICENSE.md for more information.


All versions of laravel-geo with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
guzzlehttp/guzzle Version ^7.9
illuminate/console Version ^10.0|^11.0|^12.0|^13.0
illuminate/contracts Version ^10.0|^11.0|^12.0|^13.0
illuminate/filesystem Version ^10.0|^11.0|^12.0|^13.0
illuminate/http Version ^10.0|^11.0|^12.0|^13.0
illuminate/support Version ^10.0|^11.0|^12.0|^13.0
maxmind-db/reader Version ~1.0
spatie/laravel-data Version ^4.21
spatie/laravel-package-tools Version ^1.93
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package atldays/laravel-geo contains the following files

Loading the files please wait ...