PHPackages                             awsumchan/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. [Utility &amp; Helpers](/categories/utility)
4. /
5. awsumchan/ip

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

awsumchan/ip
============

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

v1.1(6y ago)0614MITPHPPHP &gt;=5.3.0

Since May 5Pushed 6y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (3)Used By (0)

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 AwsumChan\IP\IP;
use AwsumChan\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

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 97.4% 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 ~2081 days

Total

2

Last Release

2315d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/edeed3f1021fd2ec1c6d04e69568f192cbbcde4177d94ce9041bafd53f6a9c01?d=identicon)[Circlepuller](/maintainers/Circlepuller)

---

Top Contributors

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

---

Tags

ipv6IPipv4ip-address

### Embed Badge

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

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

###  Alternatives

[s1lentium/iptools

PHP Library for manipulating network addresses (IPv4 and IPv6)

2446.2M24](/packages/s1lentium-iptools)[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)[markrogoyski/ipv4-subnet-calculator

Network calculator for subnet mask and other classless (CIDR) network information.

177813.7k6](/packages/markrogoyski-ipv4-subnet-calculator)[jalle19/php-whitelist-check

Provides a simple way to check whether an address or domain is on a whitelist

45778.7k4](/packages/jalle19-php-whitelist-check)[tholu/php-cidr-match

CIDRmatch is a library to match an IP to an IP range in CIDR notation (IPv4 and IPv6).

37211.1k](/packages/tholu-php-cidr-match)

PHPackages © 2026

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