PHPackages                             luzrain/ipcalc - 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. luzrain/ipcalc

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

luzrain/ipcalc
==============

IPv4/IPv6 Network calculator for PHP

v2.0.0(10mo ago)518.2k↓16.5%2MITPHPPHP &gt;=8.0CI passing

Since Feb 9Pushed 10mo agoCompare

[ Source](https://github.com/luzrain/ipcalc)[ Packagist](https://packagist.org/packages/luzrain/ipcalc)[ Docs](https://github.com/luzrain/ipcalc)[ RSS](/packages/luzrain-ipcalc/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (1)Versions (4)Used By (0)

🌐 IPv4/IPv6 Network calculator for PHP
======================================

[](#-ipv4ipv6-network-calculator-for-php)

[![PHP >=8.0](https://camo.githubusercontent.com/568d7867a6751717b38089414847e1fa15b210f42bbd11b8cec3cd230921ec6f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d2533453d382e302d3737376262332e7376673f7374796c653d666c6174)](https://camo.githubusercontent.com/568d7867a6751717b38089414847e1fa15b210f42bbd11b8cec3cd230921ec6f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d2533453d382e302d3737376262332e7376673f7374796c653d666c6174)[![Tests Status](https://camo.githubusercontent.com/b3a6c9a04215101e9f5bb1f284953e3fa11713b1432337f60e4cd12333f2b859/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6c757a7261696e2f697063616c632f74657374732e79616d6c3f6272616e63683d6d61696e266c6162656c3d5465737473)](https://camo.githubusercontent.com/b3a6c9a04215101e9f5bb1f284953e3fa11713b1432337f60e4cd12333f2b859/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6c757a7261696e2f697063616c632f74657374732e79616d6c3f6272616e63683d6d61696e266c6162656c3d5465737473)[![Downloads](https://camo.githubusercontent.com/a36f0ef329f9a41a6ca97c91b9841288284caf99b7b038c107a3f61ac8338e94/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6c757a7261696e2f697063616c633f6c6162656c3d446f776e6c6f61647326636f6c6f723d663238643161)](https://camo.githubusercontent.com/a36f0ef329f9a41a6ca97c91b9841288284caf99b7b038c107a3f61ac8338e94/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6c757a7261696e2f697063616c633f6c6162656c3d446f776e6c6f61647326636f6c6f723d663238643161)

This IP Network Calculator library supports both IPv4 and IPv6, offering functionality to compute usable host ranges, retrieve subnet masks, and determine whether a given IP address belongs to a specific network.

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

[](#installation)

Install with composer:

```
$ composer require luzrain/ipcalc
```

Usage
-----

[](#usage)

Create IPCalc\\IP instance

```
$net = new IPCalc\IP('192.168.1.1/24');
// or
$net = new IPCalc\IP('192.168.1.1', 24);
```

You can then retrieve various properties of the network:

```
$net->getIp();                  // 192.168.1.1    // The original IP address
$net->getNetmask();             // 255.255.255.0  // Subnet mask
$net->getCidr();                // 24             // CIDR prefix length
$net->getVersion();             // 4              // IP version (4 or 6)
$net->isPrivate();              // true           // Returns true if the IP address is in a private range
$net->getNetwork();             // 192.168.1.0    // Network address of the subnet (IPv4 only)
$net->getBroadcast();           // 192.168.1.255  // Broadcast address of the network (IPv4 only)
$net->getHostMin();             // 192.168.1.1    // First usable IP address in the subnet
$net->getHostMax();             // 192.168.1.254  // Last usable IP address in the subnet
$net->contains('192.168.1.10'); // true           // Returns true if the given IP address is within the network
```

#### Notes:

[](#notes)

Although IPv6 does not use the concept of networks and broadcasts, the ranges are still needed to do inclusive searches. Also, IPv6 has a subnet segment, but can still be supernetted/subnetted, which this takes into consideration.

###  Health Score

45

—

FairBetter than 93% of packages

Maintenance54

Moderate activity, may be stable

Popularity33

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 81.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 ~1168 days

Total

3

Last Release

319d ago

Major Versions

1.0.3 → v2.0.02025-07-04

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

v2.0.0PHP &gt;=8.0

### Community

Maintainers

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

---

Top Contributors

[![mikemackintosh](https://avatars.githubusercontent.com/u/236910?v=4)](https://github.com/mikemackintosh "mikemackintosh (13 commits)")[![luzrain](https://avatars.githubusercontent.com/u/25800964?v=4)](https://github.com/luzrain "luzrain (2 commits)")[![jaydiablo](https://avatars.githubusercontent.com/u/136907?v=4)](https://github.com/jaydiablo "jaydiablo (1 commits)")

---

Tags

cidripipv4ipv6networksubnetipv6IPnetworkcalculatoripv4cidrsubnetdtr

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/luzrain-ipcalc/health.svg)

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

###  Alternatives

[s1lentium/iptools

PHP Library for manipulating network addresses (IPv4 and IPv6)

2446.2M24](/packages/s1lentium-iptools)[markrogoyski/ipv4-subnet-calculator

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

177813.7k6](/packages/markrogoyski-ipv4-subnet-calculator)[mlocati/ip-lib

Handle IPv4, IPv6 addresses and ranges

3126.4M44](/packages/mlocati-ip-lib)[longman/ip-tools

PHP IP Tools for manipulation with IPv4 and IPv6

147245.6k6](/packages/longman-ip-tools)[rlanvin/php-ip

IPv4/IPv6 manipulation library for PHP

180738.8k11](/packages/rlanvin-php-ip)[jaaulde/php-ipv4

PHP classes for working with IPV4 addresses and networks.

1034.6k](/packages/jaaulde-php-ipv4)

PHPackages © 2026

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