Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Laravel Ip2Region

Laravel Ip2Region Laravel Package

dagasmart/laravel-ip2region

Laravel wrapper for the ip2region offline IP database. Resolve IPv4 and IPv6 addresses to country, province, city and ISP with no external API calls. Ships with a config file, facade, and Artisan command to download and update the .xdb data files. Fast local lookups for middleware and logging.

Deep Wiki
Context7

dagasmart/laravel-ip2region is a Laravel wrapper around the ip2region offline IP geolocation library, letting you resolve any IP address to its country, province, city, and ISP without external API calls or network latency. It integrates with Laravel's service container and configuration, so lookups become a single method call.

  • Offline lookups via a local xdb database — no third-party requests
  • Simple facade/helper API returning region strings or structured results
  • Configurable database path and caching strategy
  • Laravel auto-discovery with publishable config
  • Supports both IPv4 and IPv6 queries
Frequently asked questions about Laravel Ip2Region
What is dagasmart/laravel-ip2region and what problem does it solve?
It is a Laravel integration for ip2region, an offline IP geolocation database, exposed through a facade and helper. It resolves country, province, city, and ISP details for IPv4 and IPv6 addresses without calling an external API, which helps with privacy and lookup latency. You point it at a local database file and use it anywhere in your Laravel application.
How do I install dagasmart/laravel-ip2region in a Laravel application?
Install it with Composer using composer require dagasmart/laravel-ip2region, then publish any provided configuration if you need to customize the database path. Laravel package auto-discovery should register the service provider and facade. Check the package's composer.json for the exact Laravel and PHP version constraints for your release.
Do I need an API key, account, or internet connection to use it?
No. The package reads a local ip2region database file, so lookups do not call an external API, require an API key, or send visitor IP addresses to a third party. You do need to obtain and deploy the ip2region database file itself, and update it when you want fresher geolocation data.
How do I configure the path to the ip2region database file?
Publish the package configuration and set the database path to the ip2region file you want to use. Keep the file outside your public web root and deploy it with your application so lookups stay offline in every environment. If the config reads an environment variable, you can override the path per environment without editing code.
Does it support IPv6 lookups as well as IPv4?
Yes, the package is described as supporting both IPv4 and IPv6 addresses through ip2region. Make sure the database edition you deploy actually contains IPv6 data, and verify with test addresses in your environment. If a lookup misses, handle it gracefully with a default or unknown location.
What details does it return for an IP address?
Lookups can return country, province or region, city, and ISP information for an address. The exact precision depends on the ip2region database edition you deploy and on how well that IP range is represented in the data. Treat results as approximate localization rather than a precise physical address.
How do I use the facade or helper to look up an IP?
Resolve the package facade or call the provided helper with the IP address you want to inspect; the package README shows the exact class, alias, and method names for your version. Because the lookup runs against a local database, you can call it directly from controllers, middleware, form requests, or queued jobs. You can also inject the underlying service if you prefer constructor injection over facades.
Is it fast enough for production and high-traffic use?
ip2region is designed for fast local lookups, so latency is low and does not depend on a third-party API's availability or rate limits. That makes it a good fit for request-time localization, logging, and fraud checks. For very high traffic, benchmark with your chosen database edition and consider caching repeated results if you look up the same IPs often.
How do I test IP geolocation in my Laravel test suite?
Because the package is offline, you do not need to mock HTTP responses; point the configuration at a test database file containing known IP ranges. Assert against IPs whose expected country or city you have verified for that database edition, since results vary between ip2region data versions. If you use the facade, you can also swap or fake it in container bindings for tests that are not about geolocation.
How does it compare to MaxMind GeoIP2 or hosted IP geolocation APIs?
MaxMind GeoIP2 offers similar offline lookups with a different data format and licensing, while hosted APIs such as ipinfo or ipapi manage data updates for you but add network latency, rate limits, and privacy considerations. ip2region is a good fit when you want simple offline lookups with country, province, city, and ISP fields and no per-request cost. Choose based on accuracy requirements, update workflow, and whether you can ship and maintain a local database file.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
mrnewport/laravel-plaid
mrnewport/laravel-repo
mrnewport/laravel-docsign
mrnewport/laravel-stow
mrnewport/laravel-flow
mrnewport/laravel-priceable
mrnewport/laravel-nestedterms
fredmeng/laravel-apidoc-generator
itstructure/laravel-multilingual-tools
pdustdar/elasticsearch
markupai/php-sdk
rlacerda83/lumem-microservice-shipment
uni-method/symfony-lib
tacticmedia/scim-server-bundle
neika-ai/symfony-bundle
mattleads/agent-publishing-bundle
glavweb/framework-bundle
glavweb/extra-bundle
glavweb/api-bundle
glavweb/admin-bundle