定制 smalldogs/ip2country 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

smalldogs/ip2country

最新稳定版本:1.1.0

Composer 安装命令:

composer require smalldogs/ip2country

包简介

Laravel package to lookup the country associated with an IPv4 address

README 文档

README

Downloads License Version TravisCI

Laravel package to lookup the country associated with an IPv4 address. Developed with an eye to keeping it as lightweight and lookups as fast as possible. Creates and populates a local database table, so there are no external requests being made during runtime.

This package includes GeoLite data created by MaxMind, available from http://www.maxmind.com. The updated free downloadable database is released the first Tuesday of each month. I'll attempt to ensure to update this package each time.

Current IP Mapping Table

Doesn't seem to change much from month to month. Current version was released by MaxMind February 4, 2015

How to Update Mapping DB Table

If you have already installed and setup the ip2country package, but want to update the IP database mappings. First, get the latest ip2country package.

composer update 

or, to only update this pacakage

composer update smalldogs/ip2country

Then, update your database by running the new migration.

php artisan migrate --package="smalldogs/ip2country"

How to Install

1. Require the package with composer.
composer require "smalldogs/ip2country"
2. Create and populate the database lookup table.
php artisan migrate --package="smalldogs/ip2country"
3. Add the service to your providers array in app/config/app.php
'providers' => array(
        'Smalldogs\Ip2Country\Ip2CountryServiceProvider',
        //[...]
);

How to Use

// Returns the 2 letter country code for the user, eg: 'US'
$myCountryCode = Ip2Country::get();

// Returns the full name of the country, eg: 'United States'
$myCountryName = Ip2Country::getFull();

// Get the country for someone other than user on the page
$someonesIpAddress = '192.168.0.1';
$someonesCountryCode = Ip2Country::get($someonesIpAddress);

Configuration

By default, if the IP address is not found in the lookup table, it will return 'US' as a country code, and 'United States' as a country name. You can customize this in the config.

php artisan config:publish smalldogs/ip2country

Then navigate to app/config/packages/smalldogs/ip2country/config.php.

return array(
    // If IP address is not found, what country is returned
    'default_country_code' => 'US',
    'default_country_name' => 'United States',
    
    // Since our data will change, at most, once a month. Cache the Ip lookup for a day
    // Default: 1 day. Set to 0 or null to disable.
    'cache_results' => 60 * 24
);

If you don't want anything returned if the IP address is not found, simply set each of these to => null

统计信息

  • 总下载量: 1.01k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 22
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 22
  • Watchers: 5
  • Forks: 7
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-2-Clause
  • 更新时间: 2014-11-21

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固