PHPackages                             rafalmasiarek/real-ip-resolver - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. rafalmasiarek/real-ip-resolver

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

rafalmasiarek/real-ip-resolver
==============================

Simple and extensible real IP resolver for PHP behind proxies and load balancers.

1.2.1(5mo ago)010MITPHPPHP &gt;=7.4

Since Jul 25Pushed 5mo agoCompare

[ Source](https://github.com/rafalmasiarek/php-realIpResolver)[ Packagist](https://packagist.org/packages/rafalmasiarek/real-ip-resolver)[ RSS](/packages/rafalmasiarek-real-ip-resolver/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)DependenciesVersions (5)Used By (0)

RealIpResolver
==============

[](#realipresolver)

A lightweight PHP library to resolve the real client IP address, with optional support for trusted proxy lists like Cloudflare, AWS, or localhost.

Installation
------------

[](#installation)

```
composer require rafalmasiarek/real-ip-resolver

```

Basic Usage (no trusted proxy)
------------------------------

[](#basic-usage-no-trusted-proxy)

If you're not behind any proxies or load balancers, you can use the resolver directly:

```
use rafalmasiarek\Http\RealIpResolver\RealIpResolver;

$resolver = new RealIpResolver();
$realIp = $resolver->getIp();

echo "Real IP: " . $realIp;
```

Advanced Usage (with trusted proxies)
-------------------------------------

[](#advanced-usage-with-trusted-proxies)

You can specify trusted proxy IP ranges using predefined providers:

```
use rafalmasiarek\RealIpResolver;
use rafalmasiarek\RealIpResolver\TrustedProxy;
use rafalmasiarek\RealIpResolver\IPLists\Cloudflare;
use rafalmasiarek\RealIpResolver\IPLists\Localhost;

$trustedIps = array_merge(
    Localhost::get(),
    Cloudflare::get()
);

$trustedProxy = new TrustedProxy($trustedIps);$resolver = new RealIpResolver($trustedProxy);

$realIp = $resolver->getIp();
echo "Real IP: " . $realIp;
```

Creating a Custom IP List
-------------------------

[](#creating-a-custom-ip-list)

To define your own trusted proxy list, implement the `IpListInterface`:

```
namespace rafalmasiarek\RealIpResolver\IPLists;

class MyCustomProxy implements IpListInterface
{
    public static function get(): array
    {
        return [
            '203.0.113.5',
            '203.0.113.6',
            '2001:db8::abcd:1234',
        ];
    }
}
```

Using it:

```
use rafalmasiarek\RealIpResolver;
use rafalmasiarek\RealIpResolver\TrustedProxy;
use rafalmasiarek\RealIpResolver\IPLists\MyCustomProxy;

$trustedIps = MyCustomProxy::get();
$trustedProxy = new TrustedProxy($trustedIps);
$resolver = new RealIpResolver($trustedProxy);
```

Namespace Change in 1.2.0
-------------------------

[](#namespace-change-in-120)

Starting from version **1.2.0**, the library uses a cleaner and flatter namespace structure.

### What changed

[](#what-changed)

Old namespace (before 1.2.0):

```
rafalmasiarek\Http\RealIpResolver\

```

New namespace (1.2.0 and later):

```
rafalmasiarek\RealIpResolver\

```

### Updated imports

[](#updated-imports)

Before:

```
use rafalmasiarek\Http\RealIpResolver\RealIpResolver;
```

After:

```
use rafalmasiarek\RealIpResolver;
use rafalmasiarek\RealIpResolver\TrustedProxy;
use rafalmasiarek\RealIpResolver\IPLists\Cloudflare;
use rafalmasiarek\RealIpResolver\IPLists\Localhost;
```

All users should update their imports accordingly.

License
-------

[](#license)

MIT

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance70

Regular maintenance activity

Popularity5

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~40 days

Total

4

Last Release

170d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/17765d36dfdee9f4179c94861184464cb4282d224e9db7fa86b4dff6005c166c?d=identicon)[rafalmasiarek](/maintainers/rafalmasiarek)

---

Top Contributors

[![rafalmasiarek](https://avatars.githubusercontent.com/u/36776423?v=4)](https://github.com/rafalmasiarek "rafalmasiarek (1 commits)")

### Embed Badge

![Health badge](/badges/rafalmasiarek-real-ip-resolver/health.svg)

```
[![Health](https://phpackages.com/badges/rafalmasiarek-real-ip-resolver/health.svg)](https://phpackages.com/packages/rafalmasiarek-real-ip-resolver)
```

###  Alternatives

[pmill/php-scheduler

Simple PHP task scheduler

1833.5k](/packages/pmill-php-scheduler)[hydreflab/jedi-faker

Faker extension for Star Wars junkie

1429.5k1](/packages/hydreflab-jedi-faker)[yii2mod/yii2-bx-slider

Bx-slider widget based on bx-slider extension {@link http://bxslider.com)

1210.8k](/packages/yii2mod-yii2-bx-slider)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
