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

ActiveLibrary

lifo/ip
=======

IP address helper PHP library for working with IPv4 and IPv6 addresses

v1.1.1(3y ago)1894.6k↓22.8%31MITPHPPHP &gt;=5.3.0

Since May 5Pushed 3y ago3 watchersCompare

[ Source](https://github.com/lifo101/ip)[ Packagist](https://packagist.org/packages/lifo/ip)[ RSS](/packages/lifo-ip/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)DependenciesVersions (4)Used By (1)

IP Address Helper Library
-------------------------

[](#ip-address-helper-library)

IP address helper PHP library for working with IPv4 and IPv6 addresses. Convert any IP address into decimal, hex or binary and back again.

### Notes

[](#notes)

This library is not complete and is missing certain CIDR, Subnet and other miscellaneous IP features. Most of the IP conversion routines use `BCMATH` to do calculations which means this library is not the fastest it could be. Once the library is in a more stable state I may start attempting to optimize certain bits.

Feel free to send pull requests with missing functionality.

### Examples

[](#examples)

The translation routines are IP agnostic, meaning they don't care if you pass in an IPv4 or IPv6 address. All IP calculations are done in `Decimal` which is perfect for storing in databases.

```
use Lifo\IP\IP;
use Lifo\IP\CIDR:

// IPv4
echo '127.0.0.1 = ', IP::inet_ptod('127.0.0.1'), "\n";
echo IP::inet_dtop('2130706433'), " = 2130706433\n";
echo '127.0.0.1 = ', IP::inet_ptoh('127.0.0.1'), " (hex)\n";

// IPv6
echo '2001:4056::1 = ', IP::inet_ptod('2001:4056::1'), "\n";
echo IP::inet_dtop('42541793049812452694190522094162280449'), " = 42541793049812452694190522094162280449\n";
echo '2001:4056::1 = ', IP::inet_ptoh('2001:4056::1'), " (hex)\n";

// CIDR

// note: the true CIDR block is calculated from the prefix (the ::1 is ignored)
$ip = new CIDR('2001:4056::1/96');

echo "$ip\n", implode(' - ', $ip->getRange()), " (" . number_format($ip->getTotal()) . " hosts)\n";
```

```
// expected output:
127.0.0.1 = 2130706433
127.0.0.1 = 2130706433
127.0.0.1 = 7f000001 (hex)

2001:4056::1 = 42541793049812452694190522094162280449
2001:4056::1 = 42541793049812452694190522094162280449
2001:4056::1 = 20014056000000000000000000000001 (hex)

2001:4056::1/96
2001:4056:: - 2001:4056::ffff:ffff (4,294,967,296 hosts)

```

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity39

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity60

Established project with proven stability

 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 ~1495 days

Total

3

Last Release

1406d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/367337?v=4)[Jason M](/maintainers/lifo101)[@lifo101](https://github.com/lifo101)

---

Top Contributors

[![lifo101](https://avatars.githubusercontent.com/u/367337?v=4)](https://github.com/lifo101 "lifo101 (40 commits)")

---

Tags

ipv4ipv6libraryphpipv6IPipv4ip-address

### Embed Badge

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

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

###  Alternatives

[zoujingli/ip2region

ip2region v3.0 for PHP - 企业级 IP 地理位置查询库，支持 IPv4 和 IPv6，多种缓存策略，零依赖，开箱即用

1.4k437.1k56](/packages/zoujingli-ip2region)[mlocati/ip-lib

Handle IPv4, IPv6 addresses and ranges

3126.4M44](/packages/mlocati-ip-lib)[s1lentium/iptools

PHP Library for manipulating network addresses (IPv4 and IPv6)

2446.2M24](/packages/s1lentium-iptools)[darsyn/ip

An immutable IP Address value object that provides several different notations, including helper functions.

2572.0M20](/packages/darsyn-ip)[rlanvin/php-ip

IPv4/IPv6 manipulation library for PHP

180738.8k11](/packages/rlanvin-php-ip)[longman/ip-tools

PHP IP Tools for manipulation with IPv4 and IPv6

147245.6k6](/packages/longman-ip-tools)

PHPackages © 2026

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