huangdijia / laravel-ipip
ipip for laravel
1.1.1
2020-09-02 01:58 UTC
Requires
- php: >=7.0.0
- illuminate/console: ^5.5|^6.0|^7.0|^8.0
- illuminate/support: ^5.5|^6.0|^7.0|^8.0
- ipip/datx: ~0.2
README
Requirements
- PHP >= 7.0
- Laravel >= 5.5
Installation
First, install laravel 5.5, and make sure that the database connection settings are correct.
composer require huangdijia/laravel-ipip
Then run these commands to publish config
php artisan vendor:publish --provider="Huangdijia\Ipip\IpipServiceProvider"
Configurations
// config/ipip.php 'datx' => [ 'city' => 'path/mydata4vipday4.datx', 'district' => 'path/quxian.datx', 'basestation' => 'path/station_ip.datx', ], 'auth' => [ 'mail' => '', // mail of ipip.net 'pass' => '', // password of ipip.net ]
Usage
As Facade
use Huangdijia\Ipip\Facades\BaseStation; use Huangdijia\Ipip\Facades\City; use Huangdijia\Ipip\Facades\District; ... BaseStation::find('66.249.69.48'); // ['美国', '美国', '', ''] City::find('66.249.69.48'); District::find('66.249.69.48');
As Command
php artisan ipip:basestation '66.249.69.48' # ['美国', '美国', '', ''] php artisan ipip:city '66.249.69.48' php artisan ipip:district '66.249.69.48' php artisan ipip:download # must set mail and pass at config/ipip.php
As Helper
ipip('city')->find('66.249.69.48'); // ['美国', '美国', '', ''] ipip_city()->find('66.249.69.48'); // ['美国', '美国', '', ''] ipip_city('66.249.69.48'); // ['美国', '美国', '', ''] ipip('basestation')->find('66.249.69.48'); ipip_basestation()->find('66.249.69.48'); ipip_basestation('66.249.69.48'); ipip('distric')->find('66.249.69.48'); ipip_distric()->find('66.249.69.48'); ipip_distric('66.249.69.48');
Other
License
laravel-ipip is licensed under The MIT License (MIT).