geocoder-php/host-ip-provider
HostIP provider for the PHP Geocoder library. Retrieves geolocation data for an IP address using the hostip.info service, returning standard Geocoder results. Lightweight adapter to plug HostIP into geocoder-php for quick IP-to-location lookups.
geocoder-php/host-ip-provider package is a read-only provider for the HostIp geocoding service, designed to integrate with the Geocoder PHP library. It enables reverse geocoding (IP-to-location) functionality, which is useful for:
ProviderManager and inject it into services needing geocoding.$geocoder = new Geocoder\Geocoder([
'hostip' => new \Geocoder\Provider\HostIp\HostIpProvider()
]);
$location = $geocoder->geocode('123.45.67.89');
| Risk Area | Severity | Mitigation |
|---|---|---|
| HostIp API Dependencies | High | - Implement fallback providers (e.g., IPStack, MaxMind). |
| - Cache responses aggressively (e.g., Redis) to reduce API calls. | ||
| Accuracy/Compliance | Medium | - Validate against known test IPs (e.g., Google’s test IPs). |
| - Document limitations (e.g., VPN/proxy IPs may return incorrect locations). | ||
| Rate Limiting | High | - Monitor API usage; set up alerts for quota exhaustion. |
| - Use queue workers to batch requests. | ||
| License Compliance | Low | MIT license is permissive, but ensure HostIp’s terms align with your use case. |
ProviderManager with multiple providers:
$geocoder = new Geocoder\Geocoder([
'hostip' => new \Geocoder\Provider\HostIp\HostIpProvider(),
'fallback' => new \Geocoder\Provider\IpApiProvider('YOUR_API_KEY'),
]);
192.168.x.x) should return null or a default location.not.an.ip) should trigger graceful degradation.throttle middleware).class GeocoderService {
public function __construct(private GeocoderInterface $geocoder) {}
public function getLocation(string $ip): ?array { ... }
}
8.8.8.8).env(), AWS Secrets Manager).filter_var($ip, FILTER_VALIDATE_IP).error fields).null for VPN IPs").How can I help you explore Laravel packages today?