Matomo Network

A PHP library for parsing and manipulating IPv4 and IPv6 addresses.

Library
Composer
v2.0.3
21stars
LGPL-3.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
31/100Needs Attention
Development Activity12
Maintenance20
Community20
Maturity60
Momentum12

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
72/100Good
Architecture76
Code Quality74
Innovation58
Learning Curve76

Matomo Network is a PHP component, extracted from the Matomo analytics platform, that provides tools for working with IP addresses. It offers a unified IP class that transparently handles both IPv4 and IPv6, letting you parse addresses from strings or binary, compare them, and test membership in ranges and subnets.

Because analytics involves anonymising and bucketing visitor IPs at scale, the library focuses on correct, efficient conversions between string and binary representations and on range checks expressed in familiar CIDR and wildcard notations.

What You Get

  • A unified IP class abstracting over IPv4 and IPv6 addresses
  • Conversions between string, binary, and numeric IP representations
  • Range and subnet membership checks using CIDR and wildcard notation
  • IP anonymisation by masking trailing bytes
  • An IPUtils helper for common address operations

Common Use Cases

  • Checking whether a visitor IP falls inside a trusted or blocked range
  • Anonymising IP addresses to meet privacy requirements
  • Normalising IPs between string and binary forms for storage
  • Distinguishing and validating IPv4 versus IPv6 input

Under The Hood

Architecture - The core is the abstract IP class in src/, specialised by IPv4 and IPv6, with a static factory that inspects input and returns the right subtype. IPUtils holds stateless helpers for conversions and range logic. Callers work against the IP abstraction, so code handling ranges or anonymisation is largely version-agnostic between IPv4 and IPv6.

Tech Stack - Pure PHP (>=7.2) with PSR-4 autoloading under Matomo\Network\ and no runtime dependencies, relying on PHP’s native inet_pton/inet_ntop-style byte handling. PHPUnit backs the test suite.

Code Quality - The component is small and cohesive, with a clear class hierarchy and a tests/ directory. The IPv4/IPv6 split keeps version-specific edge cases contained, and the binary-oriented conversions are written with performance in mind.

API Design - Construction goes through IP::fromStringIP() / fromBinaryIP()-style factories, after which comparisons, anonymisation, and range checks read naturally. The unified abstraction means most calling code does not branch on IP version, keeping usage concise.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search