xp-forge / geoip
GeoIP database
v5.1.0
2024-03-24 10:38 UTC
Requires
- php: >=7.0.0
- xp-framework/core: ^12.0 | ^11.0 | ^10.0
- xp-framework/math: ^9.0 | ^8.0 | ^7.0
Requires (Dev)
- xp-framework/test: ^2.0 | ^1.0
README
This API allows working with data geoips of different kinds in a functional style, e.g. map/reduce.
Examples
use com\maxmind\geoip\GeoIpDatabase; use io\File; $database= GeoIpDatabase::open(new File('GeoLite2-City.mmdb')); $record= $database->lookup('8.8.8.8'); $database->close(); // $record= com.maxmind.geoip.Record@{ // [city ] com.maxmind.geoip.Name(#5375480: Mountain View) // [country ] com.maxmind.geoip.Name(#6252001: United States; code= US) // [continent ] com.maxmind.geoip.Name(#6255149: North America; code= NA) // [postalCode ] "94035" // [location ] com.maxmind.geoip.Location(37.386,-122.0838; tz= America/Los_Angeles) // [subdivisions] [com.maxmind.geoip.Name(#5332921: California; code= CA)] // }
See also
- http://dev.maxmind.com/geoip/geoip2/geolite2/ GeoLite2 Free Downloadable Databases
- http://maxmind.github.io/MaxMind-DB/ MaxMind DB File Format Specification