Download the PHP package suprun-bohdan/laravel-ip-info without Composer

On this page you can find all versions of the php package suprun-bohdan/laravel-ip-info. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-ip-info

Laravel IP Info

Latest Version on Packagist Tests Benchmarks License: MIT

Laravel package for smart IP resolution, geo lookup, and cache-first IP intelligence — trusted proxies, provider chains, offline MMDB (IPv4 + IPv6), middleware, and testing fakes.

Author: Bohdan Suprun

Quick Start

After install, public IP lookups work immediately via the HTTP provider (quick_start preset).

For production, prefer offline geo — no rate limits, no outbound HTTP:

See Offline geo guide for country vs city editions and IPv6.

Production behind Cloudflare

Add to .env:

Register client IP resolution (opt-in):

Route middleware (v4.2+)

Alias Class Purpose
ip.resolve ResolveClientIp Sets ip_info / client_ip on request
geo.block BlockCountries Block by country (geo.block:RU,BY)
geo.allow AllowCountries Allow-list only
geo.share ShareClientGeo API/Inertia geo payload
ip.log LogClientIp Structured client IP logging (v4.3+)
ip.filter FilterClientIp Block Tor/proxy/WHOIS rules (v4.3+)

IP intelligence (v4.3+)

Live WHOIS (IANA → RIR, TCP :43), threat signals, privacy profile, and optional request logging:

Key env vars: IP_INFO_WHOIS_ENABLED, IP_INFO_CLIENT_LOG_ENABLED, IP_INFO_FILTERING_ENABLED, IP_INFO_TOR_EXIT_CIDRS.

IP risk and filtering (v4.5+)

Per-reason HTTP responses, risk scoring, block events, and verified crawler bypass:

Config (config/ip-info.php):

Listen for blocks:

Blade: @highrisk@endhighrisk wraps content when risk level is high.

Blade (v4.4+)

Directives

@geoblock('RU') aborts when the client matches (uses ip-info.security.* config). For middleware-level filtering use ip.filter instead of duplicating abort logic in Blade.

Dev components (local / staging)

Publish CSS and optional view overrides:

In your layout:

Component Purpose
<x-ip-info::dev-banner /> Country, continent, EU badge, anonymized IP, privacy/threat chips
<x-ip-info::country-gate countries="UA,PL"> Slot content when client country matches; optional fallback slot
<x-ip-info::debug-panel /> Collapsible <details> dump of geo, privacy, threats (no WHOIS)

Props: dev-bannershowIp, showThreats, onlyPrivate; debug-panelcollapsed (default true).

Components use ClientGeoData and ip_info()->threats() only — no live WHOIS in views.

Helpers reference (v4.2+)

Function / macro Returns Notes
ip_info(?string $ip = null) IpInfoQuery Current request when $ip omitted
client_country(?Request $r = null, ?string $default = null) ?string Uses request memo + cache
client_city(?Request $r = null, ?string $default = null) ?string City from offline MMDB (v4.6+)
client_asn(?Request $r = null, ?int $default = null) ?int ASN from offline enrichment (v4.7+)
client_ip(?Request $r = null) string Reuses middleware attribute when set
client_ip_info(?Request $r = null) IpInfoResult Full DTO
normalize_ip(string $ip) string Canonical IP (v4.3+)
ip_privacy(?string $ip = null) IpPrivacyProfile Private/public/reserved (v4.3+)
ip_threats(?string $ip = null) IpThreatSignals Tor/proxy/VPN/hosting (v4.3+)
client_ip_intel(?Request $r = null, bool $withWhois = false) ClientIpIntel Geo + privacy + threats + WHOIS (v4.3+)
client_ip_risk(?Request $r = null) ClientIpRiskScore Weighted risk score (v4.5+)
is_verified_crawler(?string $ip = null) bool Reverse DNS verified bot (v4.5+)
whois_lookup(string $ip, bool $force = false) ?WhoisRecord Live WHOIS lookup (v4.3+)
request()->clientCountry() ?string Macro
request()->clientCity() ?string Macro (v4.6+)
request()->ipInfo() IpInfoResult Macro
request()->clientIpRisk() ClientIpRiskScore Macro (v4.5+)
request()->isVerifiedCrawler() bool Macro (v4.5+)
request()->isCountry('UA', ...) bool Macro

Fluent on IpInfoQuery / IpInfoResult: isCountry(), inCountries(), isEu(), countryOr(), countryOrFail(), city(), region(), timezone(), coordinates() (v4.6+).

Choosing a geo provider

The package tries providers in order (providers.chain). First hit wins.

Provider Data IPv6 HTTP Best for
local Built-in private/reserved rules Yes No Always first — skips lookup for LAN IPs
location_db (v4.6+) Country or city MMDB Yes No Recommended production offline
database Legacy CSV → ip_country table No No Existing installs, IPv4 country only
maxmind GeoLite2 MMDB Yes No Teams with MaxMind license
http ipinfo / ip-api Yes Yes Dev / quick start
cleantalk CleanTalk API Varies Yes Optional enrichment

New projects: use location_db with --preset=offline.
Legacy projects: keep database enabled; add location_db ahead of it in the chain for IPv6 and city.

Performance and cache-first design

Lookups are cache-first: request memo → Laravel cache (positive + negative TTL) → provider chain. Private IPs never hit external providers.

Path Typical latency
Cache hit (same country code) ~0.03 ms
Offline MMDB (location_db) ~0.1 ms
HTTP provider (quick_start) 50–500+ ms

Measure in your environment:

User guide: bench/README.md

v4.7+: Cache v2 (:v2: keys) stores a JSON geo payload — city, region, timezone, and ASN survive cache hits when enabled via IP_INFO_CACHE_STORE_GEO_FIELDS=true (default). Fields respect the location_db.fields whitelist.

Security model (client IP)

  • Never trust X-Forwarded-For blindly. Headers are read only when the remote address matches trusted_proxies.proxy_cidrs, unless require_trusted_proxy_for_headers=false.
  • Mirror Laravel TrustProxies when using respect_laravel=true (default).
  • Cloudflare presets require IP_INFO_TRUSTED_PROXY_CIDRS. Refresh with ip-info:refresh-cloudflare-cidrs.
  • Runtime presetsIP_INFO_PRESET=cloudflare|nginx_proxy|offline|quick_start|local_only (merged on each boot).
  • HTTP providers use HTTPS by default. Insecure http:// URLs require IP_INFO_HTTP_ALLOW_INSECURE=true.

Testing

IpInfo::fake() bypasses positive/negative cache and skips cache writes during tests.

Benchmarks and stress

Full guide: bench/README.md

Docker verification

Run the full package suite and an ephemeral Laravel 11 app (path repo) inside Docker:

Micro-benchmarks without Docker:

No demo app is committed to the repository; docker/verify.sh and docker/stress.sh bootstrap a temporary app in a Docker volume.

What this package does

  • Normalizes and validates IPv4/IPv6 input.
  • Classifies public, private, localhost, link-local, and reserved addresses.
  • Resolves client IP from HTTP requests with trusted-proxy awareness.
  • Looks up country codes through a provider chain (local, location_db, database, maxmind, http, cleantalk).
  • Offline city, region, timezone, and coordinates via MMDB (location_db, v4.6+).
  • Caches lookups with configurable positive and negative TTL (cache-first).
  • Built-in benchmarks and Docker stress tests for cache, MMDB, and HTTP paths.
  • Geo block/allow middleware, validation rules, sync/diagnose tooling.

Requirements

  • PHP ^8.2
  • Laravel ^10, ^11, or ^12
  • Laravel cache (array, file, redis, etc.)
  • Database optional (legacy offline IPv4 CSV lookup)
  • maxmind-db/reader optional (MaxMind GeoLite2 and ip-location-db MMDB)

Installation options

Publish configuration only:

Offline geo without HTTP (v4.6+)

Full user guide: docs/offline-geo.md

Download DB-IP Lite MMDB files via sapics/ip-location-db (CC BY 4.0 — attribute db-ip.com when displaying geo data to users).

Limit returned fields in config/ip-info.phplocation_db.fields (whitelist at lookup time).

Legacy IPv4 CSV (still supported, separate from MMDB):

Optional MaxMind GeoLite2:

Application sync

--fix performs safe actions only: publish missing stubs and migrate. Middleware registration and schedule stubs require explicit flags.

When routes are enabled:

Configuration

File: config/ip-info.php

Section Purpose
active_preset / IP_INFO_PRESET Runtime preset merge (cloudflare, offline, quick_start, …)
cache TTL, negative cache, prefix, tenant prefix
providers.chain Provider order
presets Named proxy/provider bundles
security Blocked/allowed countries, response status/message
database Legacy offline IPv4 CSV (ip_country table)
location_db Offline MMDB — edition, path, field whitelist (v4.6+)
maxmind GeoLite2 MMDB path and license key
http Driver (ipinfo, ip-api), HTTPS enforcement
trusted_proxies Header allowlist, proxy CIDRs
routes Opt-in API endpoint
privacy Logging policy via IpPrivacyPolicy

Commands

Command Description
ip-info:install Publish config, migrate, optional preset
ip-info:install --quick Enable HTTP geo (quick_start preset)
ip-info:install --register-middleware Register ResolveClientIp (opt-in)
ip-info:install --with-schedule Append update stubs to routes/console.php
ip-info:install --with-location-db Download country MMDB (IPv4 + IPv6)
ip-info:install --with-location-db=city Download city MMDB edition
ip-info:install --with-location-db=asn_country Download ASN-country MMDB (CC0, v4.7+)
ip-info:install --with-asn-db Download ASN enrichment MMDB (v4.7+)
ip-info:install --preset=offline Chain without HTTP (location_db)
ip-info:refresh-cloudflare-cidrs Fetch Cloudflare egress CIDRs for .env
ip-info:sync Audit integration (config, middleware, routes, security)
ip-info:diagnose Provider health + optional IP lookup
ip-info:about Capability matrix (preset, helpers, aliases)
ip-info:starter Publish middleware + install bundle
ip-info:update-database Refresh offline IPv4 CSV
ip-info:update-location-db Download ip-location-db MMDB files
ip-info:update-maxmind Download GeoLite2 MMDB (--edition=country\|city\|asn)
composer bench Run cache + MMDB micro-benchmarks
make docker-stress Benchmarks + HTTP wrk stress (Docker)

Architecture

Layer Role
IpInfoManager Orchestration, cache, events, fake mode
IpProviderResolver Injectable provider access
ChainProvider Ordered providers; stops on hit/miss
PresetConfigurator Runtime preset merge from .env
IpCache Positive + negative TTL cache
Custom providers providers.custom or IpInfoBuildingChain event

Documentation

Public docs: docs/README.md

Guide Description
Offline geo MMDB install, .env, city API, updates, troubleshooting (v4.6+)
Performance & benchmarks Cache-first design, composer bench, make docker-stress
Migration guide Upgrades and breaking changes
vs alternatives Comparison with other Laravel geo packages

Development

Local Docker sandbox (gitignored): cd sandbox && make init && make test

License

MIT. See LICENSE.


All versions of laravel-ip-info with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
psr/http-client Version ^1.0
psr/http-factory Version ^1.0
psr/http-message Version ^2.0
illuminate/support Version ^10.0|^11.0|^12.0
illuminate/http Version ^10.0|^11.0|^12.0
illuminate/cache Version ^10.0|^11.0|^12.0
illuminate/bus Version ^10.0|^11.0|^12.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package suprun-bohdan/laravel-ip-info contains the following files

Loading the files please wait ...