josantonius/ip
A lightweight PHP library for retrieving the client IP address, with helpers to validate IPs, detect private or reserved ranges, and handle proxied requests. Framework-agnostic and easy to drop into Laravel or any PHP project.
RequestContext/ClientIpResolver capability early, with tests for spoofed headers, IPv6, and trusted-proxy configuration — rather than letting three teams each paste a different snippet.Consider it only under narrow conditions:
X-Forwarded-For, X-Real-IP, CF-Connecting-IP, etc.) to review before writing your own — treat it as documentation, not a dependency.Look elsewhere — or build — when:
$request->ip() with properly configured TrustProxies/trusted_proxies, or Request::getClientIp(), already solves this with framework-maintained security fixes. Adding a package here is net-negative.X-Forwarded-For is client-spoofable; you need an explicit trusted-proxy allowlist and header precedence you control and can test.To executives: The relevant question is not whether to adopt this specific library — it's a tiny, archived, low-adoption utility — but whether we have one trustworthy way to know where a request came from. That single capability quietly underpins localization, pricing, fraud controls, and audit logging, and it carries privacy obligations. My recommendation: do not add this as a dependency. Fund a small internal component (roughly a day of engineering plus tests) that we own, review, and can extend. Cost is negligible; the value is avoiding divergent, untested IP logic across teams and avoiding a stale third-party dependency in a security-adjacent path.
To engineering: This package is ~a few dozen lines reading $_SERVER headers, last released mid-2022, archived, zero dependents. On Laravel, use $request->ip() with a correct TrustProxies configuration; on Symfony, Request::getClientIp() with trusted proxies. Where we're outside a framework, vendor the header-precedence logic into our own helper with tests covering spoofed X-Forwarded-For, multi-hop proxy chains, IPv6, and missing headers. Either way, we treat client IP as untrusted input and never use it as an authorization signal.
To security/compliance: IP is personal data in several jurisdictions. Owning the resolver lets us enforce truncation/masking at capture, define retention, and document exactly which proxy headers we honor — all of which are hard to guarantee when the logic lives in an archived dependency we don't control.
How can I help you explore Laravel packages today?