Download the PHP package dive-be/laravel-geo without Composer

On this page you can find all versions of the php package dive-be/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

Social Card of Laravel Dry Requests

🌍 - Translate IP addresses into geo locations

Latest Version on Packagist Total Downloads

This package will assist you in grabbing a visitor's country.

What problem does this package solve?

Depending on the context of your application, you may want to display content tailored for a specific country/region of the visitor. This package will help with providing a sensible default using IP addresses if it is a first time visit for a user.

Installation

You can install the package via composer:

You will also need to install GeoIP2 if you're planning to use their services:

You can publish the config file with:

This is the content of the config file:

Usage

First, you will have to decide which service to use.

Detectors

When you've decided, set the GEO_DETECTORS_DRIVER environment variable to the correct value. Refer to the configuration file for the right values.

GeoIP2 Databases

Auto updating local database

IP address ranges tend to become out of date over time. Therefore, this package also provides a convenient update command which you can schedule to run once a week to keep everything fresh.

Only applicable if using MaxMind's GeoIP2 Databases.

GeoIP2 Precision Web Services

IP 2 Country

This is a free service. You don't have to configure anything.

Note: it is strongly recommended to enable caching for this driver.

Static

The static driver is meant for usage during local development and testing. You should not use it in any other environment as it is always going to return the fallback value.

Detecting a visitor's geo location

Add the DetectGeoLocation (or alias geo) middleware to your kernel's web middleware stack and you are good to go. If your app is behind a proxy/load balancer, make sure DetectGeoLocation is defined after TrustProxies.

Retrieving the detected country 🗺

There are multiple ways to retrieve the detected ISO alpha-2 country code.

Facade

or using the alias

Helper

Dependency injection

Transforming the detected geo location 🔷

It is a high probability that you'd like to transform the ISO alpha-2 country code into your own Eloquent model or value object after calling get on the repository class. You may define your own CountryTransformer which implements the Transformer interface and simply returns the desired object.

e.g.

After defining the class, make sure to provide the FQCN in the configuration file.

Overwriting existing country ✍🏼

At any point in time, you may overwrite the detected country code. Simply call:

Clearing the cache 🔥

When enabled, the translated addresses will be held in cache for a certain amount of time defined in the configuration file. If you'd like to wipe these translations, use the command:

Note: the cache driver must support tagging or else everything will be cleared when the command above is run.

Extending the detectors 👣

If the default drivers do not fulfill your needs, you may extend the DetectorManager with your own custom drivers:

Testing 🔎

This package offers fake implementations of the Repository & Detector contracts so you can make assertions in your unit tests and make sure you ship that bug-free code 💪. Just call fake on either of them and you're set:

Testing (package)

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of laravel-geo with dependencies

PHP Build Version
Package Version
Requires php Version ~8.3
illuminate/cache Version ^11.0
illuminate/console Version ^11.0
illuminate/contracts Version ^11.0
illuminate/cookie Version ^11.0
illuminate/http Version ^11.0
illuminate/support Version ^11.0
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 dive-be/laravel-geo contains the following files

Loading the files please wait ....