Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/saeedvaziry/ip2location
Laravel IP to Location
https://github.com/saeedvaziry/ip2location
Last synced: 2 months ago
JSON representation
Laravel IP to Location
- Host: GitHub
- URL: https://github.com/saeedvaziry/ip2location
- Owner: saeedvaziry
- License: mit
- Created: 2020-10-30T22:37:48.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2024-05-01T21:03:21.000Z (8 months ago)
- Last Synced: 2024-10-12T11:11:58.325Z (3 months ago)
- Language: PHP
- Size: 1.81 MB
- Stars: 29
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- Funding: .github/FUNDING.yml
- License: LICENSE.md
Awesome Lists containing this project
README
# Laravel IP2Location Package
[![](https://img.shields.io/packagist/v/saeedvaziry/ip2location.svg?style=flat-square)](https://packagist.org/packages/saeedvaziry/ip2location)
![](https://github.com/saeedvaziry/ip2location/workflows/Test/badge.svg)
[![StyleCI](https://github.styleci.io/repos/308758323/shield?branch=master)](https://github.styleci.io/repos/308758323?branch=master)
![](https://img.shields.io/packagist/dt/saeedvaziry/ip2location)IP2Location is a small Laravel package that converts IPs to location.
This package is a wrapper to [IP2Location](https://github.com/chrislim2888/IP2Location-PHP-Module).
## Installation
```shell
composer require saeedvaziry/ip2location
```
## Updating IP databaseAfter the installation, you need to run the following command for updating the IP database.
```shell
php artisan ip2location:update
```
You can also set a scheduler in your `app/Console/Kernel.php` to keep it up to date.## Usage
### Facade
You can use `\SaeedVaziry\IP2Location\Facades\IP2Location` facade to access to all supported methods.
```php
// returns an array
\SaeedVaziry\IP2Location\Facades\IP2Location::info($ipAddress);// returns the country full name
\SaeedVaziry\IP2Location\Facades\IP2Location::countryName($ipAddress);// returns the country 2 character ISO code
\SaeedVaziry\IP2Location\Facades\IP2Location::countryCode($ipAddress);
```
### Helper functionsYou may want to access to the methods via helper functions.
```php
// returns an array
ip2location_info($ipAddress);// returns the country full name
ip2location_country_name($ipAddress);// returns the country 2 character ISO code
ip2location_country_code($ipAddress);
```
If you don't pass the `$ipAddress` in both Facade and Helper, The method will extract the IP address from the Http request.## License
IP2Location is licensed under The MIT License (MIT).