Coder Social home page Coder Social logo

adgeekedwardai / ip-location-zh Goto Github PK

View Code? Open in Web Editor NEW

This project forked from zhuzhichao/ip-location-zh

0.0 0.0 0.0 19.17 MB

获取 IP 地址的真实地理位置

Home Page: https://packagist.org/packages/zhuzhichao/ip-location-zh

License: MIT License

PHP 100.00%

ip-location-zh's Introduction

Ip Location Zh

Scrutinizer Code Quality Build Status Total Downloads Latest Stable Version License

数据最后更新时间为 2019-7-3, 更新时间:不定期。 数据源于: http://www.ipip.net

IPIP典型客户 ipip客户

这是一个能够通过 Ip,获取该 IP 所在的位置,例如通过 ip:171.12.10.156 可以获得是 **河南郑州,以及**行政区划代码(支持到市级), 同样能获得国外的地址,但是没有国内详细。

注意: 该免费数据库不提供经纬度、运营商、行政区等更详细的内容, 如果你有更多的需求可以考虑使用他们的收费服务。本包的目的是提供给需求简单, 手里没钱的程序员或者老板不舍得掏钱来获取定时更新的IP信息

国家码和邮编不是该包负责的内容, 需自行构建相关的程序

特点

  1. 不配置和使用数据库,妈妈再也不用担心配置问题了
  2. 使用简单,功能专(dān)注(yī)
  3. 使用 composer 进行安装管理,国际标准,方便快捷,即安即用,随时更新数据库

Install

这里不详细介绍安装 composer 了,大家根据 链接 自行安装吧!

composer require "zhuzhichao/ip-location-zh"

Usage

Common

可以这样来用

require 'vendor/autoload.php';


use Zhuzhichao\IpLocationZh\Ip;


var_dump(Ip::find('171.12.10.156'));
// 返回结果
array (size=4)
  0 => string '**' (length=6)
  1 => string '河南' (length=6)
  2 => string '郑州' (length=6)
  3 => string '' (length=0)
  4 => string '410100' (length=6)

Laravel

对于laravel可以这样优雅的用:

1.安装该插件

2.在 config/app.php(Laravel 5.0 - 5.4)添加下面的代码,如果是 Laravel 5.5+ ,已经支持扩展包发现,不需要添加下面的代码

// Laravel 5.5 不需要添加
'aliases' => [
    'Ip'  => 'Zhuzhichao\IpLocationZh\Ip',

],

3.然后开始在你的项目里面使用了 Ip::find('171.12.10.156')Ip::find(Request::getClientIp())

对,很简单,只用一个方法,那就是 find

Contributing

有什么新的想法和建议,欢迎提交 issue 或者 Pull Requests

License

MIT

ip-location-zh's People

Contributors

douyux avatar iflamed avatar kwaziidev avatar wblucky avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.