PHPackages                             josantonius/ip - 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. josantonius/ip

AbandonedArchivedLibrary

josantonius/ip
==============

PHP class to get user IP.

1.1.8(3y ago)1118.3k↓50%45MITPHPPHP ^5.6 || ^7.0

Since Jan 17Pushed 3y ago3 watchersCompare

[ Source](https://github.com/josantonius/php-ip)[ Packagist](https://packagist.org/packages/josantonius/ip)[ GitHub Sponsors](https://github.com/Josantonius)[ RSS](/packages/josantonius-ip/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (4)Versions (12)Used By (5)

PHP Ip library
==============

[](#php-ip-library)

[![Latest Stable Version](https://camo.githubusercontent.com/deab0d6515fb167c626c4e9627c1514ac310215959e1c78325f84215c6407096/68747470733a2f2f706f7365722e707567782e6f72672f6a6f73616e746f6e6975732f49702f762f737461626c65)](https://packagist.org/packages/josantonius/Ip)[![License](https://camo.githubusercontent.com/b9b4f7fc463fbb5f9cecd690aeedec6ab7b2fb0d64003cb99372110b7e8793de/68747470733a2f2f706f7365722e707567782e6f72672f6a6f73616e746f6e6975732f49702f6c6963656e7365)](LICENSE)

[Versión en español](README-ES.md)

PHP class to get user IP.

> After reviewing the code after a few years, I would not recommend the use of the class for a production site, as preference was given to headers easily manipulated by the user to get the IP.

> If the reliability of the header from which the IP will be obtained is not guaranteed, it is better to use $\_SERVER\['REMOTE\_ADDR'\] directly or develop a custom solution.

---

- [Requirements](#requirements)
- [Installation](#installation)
- [Available Methods](#available-methods)
- [Quick Start](#quick-start)
- [Usage](#usage)
- [Tests](#tests)
- [Sponsor](#Sponsor)
- [License](#license)

---

Requirements
------------

[](#requirements)

This library is supported by **PHP versions 5.6** or higher and is compatible with **HHVM versions 3.0** or higher.

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

[](#installation)

The preferred way to install this extension is through [Composer](http://getcomposer.org/download/).

To install **PHP Ip library**, simply:

```
composer require Josantonius/Ip

```

The previous command will only install the necessary files, if you prefer to **download the entire source code** you can use:

```
composer require Josantonius/Ip --prefer-source

```

You can also **clone the complete repository** with Git:

$ git clone

Or **install it manually**:

[Download Ip.php](https://raw.githubusercontent.com/Josantonius/PHP-Ip/master/src/Ip.php):

```
wget https://raw.githubusercontent.com/Josantonius/PHP-Ip/master/src/Ip.php

```

Available Methods
-----------------

[](#available-methods)

Available methods in this library:

### - Get user's IP

[](#--get-users-ip)

```
Ip::get();
```

**\# Return** (string|false) → user IP or false

### - Validate IP

[](#--validate-ip)

```
Ip::validate($ip);
```

AttributeDescriptionTypeRequiredDefault$ipIP address to be validated.stringYes**\# Return** (boolean)

Quick Start
-----------

[](#quick-start)

To use this library with **Composer**:

```
require __DIR__ . '/vendor/autoload.php';

use Josantonius\Ip\Ip;
```

Or If you installed it **manually**, use it:

```
require_once __DIR__ . '/Ip.php';

use Josantonius\Ip\Ip;
```

Usage
-----

[](#usage)

Example of use for this library:

### - Get user's IP

[](#--get-users-ip-1)

```
Ip::get();
```

### - Validate IP

[](#--validate-ip-1)

```
$ip = Ip::get();

Ip::validate($ip);
```

Tests
-----

[](#tests)

To run [tests](tests) you just need [composer](http://getcomposer.org/download/) and to execute the following:

```
git clone https://github.com/Josantonius/PHP-Ip.git

cd PHP-Ip

composer install

```

Run unit tests with [PHPUnit](https://phpunit.de/):

```
composer phpunit

```

Run [PSR2](http://www.php-fig.org/psr/psr-2/) code standard tests with [PHPCS](https://github.com/squizlabs/PHP_CodeSniffer):

```
composer phpcs

```

Run [PHP Mess Detector](https://phpmd.org/) tests to detect inconsistencies in code style:

```
composer phpmd

```

Run all previous tests:

```
composer tests

```

Sponsor
-------

[](#sponsor)

If this project helps you to reduce your development time, [you can sponsor me](https://github.com/josantonius#sponsor) to support my open source work 😊

License
-------

[](#license)

This repository is licensed under the [MIT License](LICENSE).

Copyright © 2017-2022, [Josantonius](https://github.com/josantonius#contact)

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity33

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 90.3% 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 ~288 days

Recently: every ~437 days

Total

8

Last Release

1388d ago

PHP version history (2 changes)1.0.0PHP &gt;=7.0

1.1.1PHP ^5.6 || ^7.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/4b221283501ec8a9cbaefaf27821a91ae8ddd33bddf1fccc6c6815b7ad216ff1?d=identicon)[Josantonius](/maintainers/Josantonius)

---

Top Contributors

[![josantonius](https://avatars.githubusercontent.com/u/18104336?v=4)](https://github.com/josantonius "josantonius (28 commits)")[![MASNathan](https://avatars.githubusercontent.com/u/2139464?v=4)](https://github.com/MASNathan "MASNathan (3 commits)")

---

Tags

phpphp-ipphphhvmIPREMOTE\_ADDRGet user IP

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/josantonius-ip/health.svg)

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

###  Alternatives

[ifsnop/mysqldump-php

PHP version of mysqldump cli that comes with MySQL

1.3k5.5M69](/packages/ifsnop-mysqldump-php)[clouddueling/mysqldump-php

PHP version of mysqldump cli that comes with MySQL

1.3k22.9k](/packages/clouddueling-mysqldump-php)[derptest/phpmachinist

Testing object factory for PHP

3636.9k1](/packages/derptest-phpmachinist)

PHPackages © 2026

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