torann/geoip
GeoIP for Laravel resolves visitor location and currency from IP addresses via configurable services. Integrates with Laravel, supports multiple drivers/providers, and lets you publish config to choose and tune your lookup service.
GeoIP::getLocation()) and service bindings, ensuring testability and dependency clarity. Supports interface-based contracts (e.g., GeoIPInterface) for future-proofing.geoip.resolved) for decoupled extensions (e.g., analytics, logging, or custom business logic). Compatible with Laravel’s event system for observability and cross-cutting concerns.geoip:location:{ip}) reduces provider API calls by 90%, improving latency and cost efficiency. Supports Redis/Memcached for high-scale applications.config/geoip.php (published via vendor:publish) enables runtime provider switching, API key management, and feature toggles without code changes. Adheres to Laravel’s 12-factor principles.php artisan vendor:publish --provider="Torann\GeoIP\GeoIPServiceProvider"). Mitigate by testing in staging before production rollout.config/geoip.php).app/Http/Kernel.php), enabling request-level geolocation.composer require torann/geoip
php artisan vendor:publish --provider="Torann\GeoIP\GeoIPServiceProvider"
config/geoip.php:
ipdata.co for GDPR compliance).config/app.php (if not auto-discovered):
'providers' => [
Torann\GeoIP\GeoIPServiceProvider::class,
],
GeoIPMiddleware to the stack (e.g., in app/Http/Kernel.php):
protected $middleware = [
\Torann\GeoIP\Middleware\GeoIPMiddleware::class,
];
$location = GeoIP::getLocation();
$country = $location->countryCode;
.env (e.g., CACHE_DRIVER=redis).GeoIP::setCacheTTL(3600); // 1 hour
GeoIP::shouldReceive('getLocation')->andReturn(new Location(['countryCode' => 'US']));
spatie/laravel-cache).spatie/laravel-middleware).How can I help you explore Laravel packages today?