- How do I install cimus/ip-geo-base in Laravel?
- Run `composer require cimus/ip-geo-base` or add it to your `composer.json` under `require`. The package integrates seamlessly with Laravel’s autoloader for versions 5.5+.
- What Laravel versions does this package support?
- The package works with Laravel 8.x, 9.x, and 10.x. For older versions (5.5+), manually register the service provider if autoloading fails.
- How do I initialize the IP geolocation database?
- Use `IpGeoBaseUtil` to load and convert the archive: `$util->loadArchive($path); $util->convertInBinary($path);`. Store the binary DB in a `DB/` directory.
- Can I use this package with MySQL or PostgreSQL instead of SQLite?
- Yes, but SQLite is default for simplicity. For production, migrate to MySQL/PostgreSQL and add indexes on `ip_from`/`ip_to` columns for faster range queries.
- How often should I update the IP geolocation data?
- Schedule weekly cron jobs to update via `php artisan ipgeobase:update`. Daily updates are recommended for high accuracy, but adjust based on your use case.
- What performance should I expect without caching?
- SQLite queries typically return in **<50ms** for single lookups. For high traffic (e.g., 10K+ QPS), implement Redis caching to reduce latency to **<10ms**.
- Does this package support IPv6 addresses?
- Limited support in the base package. For full IPv6, you may need to extend the `IpGeoBase` class or use a fork with custom IPv6 range handling.
- How can I integrate this into Laravel middleware?
- Create middleware to attach geo data to requests: `Request::ipGeo()` or use a facade like `Geo::country($ip)`. Example: `app/Http/Middleware/GeoData.php`.
- What are the licensing costs for ipgeobase.ru data?
- Check ipgeobase.ru’s licensing terms—some databases require commercial licenses for production. Free tiers may suffice for testing or low-traffic apps.
- Are there alternatives to this package for Laravel?
- Consider cloud APIs like AWS Location Service or MaxMind GeoIP2 for managed solutions. For self-hosted, compare with `spatie/geoip` (IP2Location) or `rubix/ml-geoip` (machine learning).