{"id":16676063,"url":"https://github.com/markrogoyski/ipv4-subnet-calculator-php","last_synced_at":"2026-01-16T14:24:28.242Z","repository":{"id":24603517,"uuid":"28012101","full_name":"markrogoyski/ipv4-subnet-calculator-php","owner":"markrogoyski","description":"Network calculator for subnet mask and other classless (CIDR) network information.","archived":false,"fork":false,"pushed_at":"2026-01-10T21:36:40.000Z","size":638,"stargazers_count":174,"open_issues_count":6,"forks_count":42,"subscribers_count":10,"default_branch":"master","last_synced_at":"2026-01-11T06:34:42.242Z","etag":null,"topics":["cidr","cidr-subnet","ip","ip-address","ipv4","ipv4-address","ipv4-calculator","ipv4-network","ipv4-subnetting","network","networking"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/markrogoyski.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2014-12-14T23:33:13.000Z","updated_at":"2026-01-10T21:35:36.000Z","dependencies_parsed_at":"2025-05-17T12:09:14.802Z","dependency_job_id":"0d81c340-1a86-4342-8ff7-91f2a0da3091","html_url":"https://github.com/markrogoyski/ipv4-subnet-calculator-php","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/markrogoyski/ipv4-subnet-calculator-php","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markrogoyski%2Fipv4-subnet-calculator-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markrogoyski%2Fipv4-subnet-calculator-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markrogoyski%2Fipv4-subnet-calculator-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markrogoyski%2Fipv4-subnet-calculator-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/markrogoyski","download_url":"https://codeload.github.com/markrogoyski/ipv4-subnet-calculator-php/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markrogoyski%2Fipv4-subnet-calculator-php/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28479393,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T11:59:17.896Z","status":"ssl_error","status_checked_at":"2026-01-16T11:55:55.838Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cidr","cidr-subnet","ip","ip-address","ipv4","ipv4-address","ipv4-calculator","ipv4-network","ipv4-subnetting","network","networking"],"created_at":"2024-10-12T13:08:58.190Z","updated_at":"2026-01-16T14:24:28.236Z","avatar_url":"https://github.com/markrogoyski.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"![IPV4 Subnet Calculator Logo](https://github.com/markrogoyski/ipv4-subnet-calculator-php/blob/master/docs/image/ipv4-subnet-calculator-logo.png?raw=true)\n\nIPv4 Subnet Calculator (PHP)\n============================\n\nComprehensive PHP library for IPv4 subnet calculations, network planning, and CIDR operations.\n\n[![Coverage Status](https://coveralls.io/repos/github/markrogoyski/ipv4-subnet-calculator-php/badge.svg?branch=master)](https://coveralls.io/github/markrogoyski/ipv4-subnet-calculator-php?branch=master)\n[![License](https://poser.pugx.org/markrogoyski/ipv4-subnet-calculator/license)](https://packagist.org/packages/markrogoyski/ipv4-subnet-calculator)\n[![Latest Stable Version](https://poser.pugx.org/markrogoyski/ipv4-subnet-calculator/v)](https://packagist.org/packages/markrogoyski/ipv4-subnet-calculator)\n[![Downloads](https://poser.pugx.org/markrogoyski/ipv4-subnet-calculator/downloads)](https://packagist.org/packages/markrogoyski/ipv4-subnet-calculator)\n\nQuick Start\n-----------\n\n```php\n\u003c?php\nrequire_once(__DIR__ . '/vendor/autoload.php');\n\n// Create from CIDR notation\n$subnet = IPv4\\SubnetCalculatorFactory::fromCidr('192.168.1.0/24');\n\n// Get network information\necho $subnet-\u003egetNetworkPortion();           // 192.168.1.0\necho $subnet-\u003egetBroadcastAddress();         // 192.168.1.255\necho $subnet-\u003egetNumberAddressableHosts();   // 254\n\n// Check if an IP is in the subnet\n$subnet-\u003eisIPAddressInSubnet('192.168.1.100');  // true\n```\n\n**[View Complete Documentation →](docs/)**\n\nFeatures\n--------\n\n### Core Capabilities\n * **Network Calculations** - Subnet masks, wildcard masks, network/host portions, broadcast addresses\n * **IP Address Operations** - Range detection, type classification (private, public, loopback, multicast, etc.)\n * **Network Analysis** - Overlap detection, containment checking, conflict validation\n * **CIDR Operations** - Aggregation, supernetting, subnet splitting\n * **Capacity Planning** - Utilization analysis, optimal subnet sizing, waste calculation\n * **Advanced IPAM** - Subnet exclusion, address space carving, sequential allocation\n\n### Output Formats\n * Multiple formats: dotted decimal, hex, binary, integer, quads array\n * Reports: JSON, associative arrays, formatted text, printed output\n * Reverse DNS: IPv4 ARPA domain generation\n\n### Use Cases\n * Network planning and IP address management (IPAM)\n * Firewall rule validation and conflict detection\n * BGP route summarization and optimization\n * DHCP scope configuration\n * DNS reverse zone setup\n * Network automation and infrastructure-as-code\n\n**[Complete Feature List →](docs/core-features.md)**\n\nInstallation\n------------\n\n### Using Composer (Command Line)\n\n```bash\ncomposer require markrogoyski/ipv4-subnet-calculator:4.*\n```\n\n### Or Add to composer.json\n\n```json\n{\n  \"require\": {\n    \"markrogoyski/ipv4-subnet-calculator\": \"4.*\"\n  }\n}\n```\n\nThen run:\n```bash\ncomposer install\n```\n\n### Requirements\n * **PHP 7.2+** (For PHP 5.5-7.1, use [v3.1](https://github.com/markrogoyski/ipv4-subnet-calculator-php/releases/tag/v3.1.0))\n\n**[Detailed Installation Guide →](docs/getting-started.md)**\n\nUsage\n-----\n\n### Creating Subnet Calculators\n\n```php\n// From CIDR notation\n$subnet = IPv4\\SubnetCalculatorFactory::fromCidr('192.168.1.0/24');\n\n// From subnet mask\n$subnet = IPv4\\SubnetCalculatorFactory::fromMask('192.168.1.0', '255.255.255.0');\n\n// From IP range\n$subnet = IPv4\\SubnetCalculatorFactory::fromRange('192.168.1.0', '192.168.1.255');\n\n// From host count requirement\n$subnet = IPv4\\SubnetCalculatorFactory::fromHostCount('192.168.1.0', 100);\n```\n\n**[All Creation Methods →](docs/getting-started.md#creating-subnet-calculators)**\n\n### Basic Network Information\n\n```php\n$subnet = IPv4\\SubnetCalculatorFactory::fromCidr('192.168.112.203/23');\n\n// Network properties\n$subnet-\u003egetNetworkPortion();           // 192.168.112.0\n$subnet-\u003egetBroadcastAddress();         // 192.168.113.255\n$subnet-\u003egetNumberAddressableHosts();   // 510\n\n// Subnet mask and wildcard\n$subnet-\u003egetSubnetMask();               // 255.255.254.0\n$subnet-\u003egetWildcardMask();             // 0.0.1.255 (for Cisco ACLs)\n\n// Address ranges\n$subnet-\u003egetIPAddressRange();           // [192.168.112.0, 192.168.113.255]\n$subnet-\u003egetMinHost();                  // 192.168.112.1\n$subnet-\u003egetMaxHost();                  // 192.168.113.254\n```\n\n**[Network Component Access →](docs/core-features.md#network-component-access)**\n\n### Network Overlap \u0026 Conflict Detection\n\n```php\n$subnet1 = IPv4\\SubnetCalculatorFactory::fromCidr('192.168.1.0/24');\n$subnet2 = IPv4\\SubnetCalculatorFactory::fromCidr('192.168.1.128/25');\n\n// Check for overlaps\n$subnet1-\u003eoverlaps($subnet2);           // true\n\n// Check containment\n$subnet1-\u003econtains($subnet2);           // true\n$subnet2-\u003eisContainedIn($subnet1);      // true\n\n// Check if IP is in subnet\n$subnet1-\u003eisIPAddressInSubnet('192.168.1.100');  // true\n```\n\n**[Overlap Detection Guide →](docs/core-features.md#network-overlap-and-containment)**\n\n### IP Address Type Classification\n\n```php\n$private = IPv4\\SubnetCalculatorFactory::fromCidr('192.168.1.1/32');\n$private-\u003eisPrivate();    // true (RFC 1918)\n$private-\u003eisPublic();     // false\n\n$loopback = IPv4\\SubnetCalculatorFactory::fromCidr('127.0.0.1/32');\n$loopback-\u003eisLoopback();  // true\n```\n\nSupported types: private, public, loopback, link-local, multicast, carrier-grade-nat, documentation, benchmarking, reserved, and more.\n\n**[All IP Address Types →](docs/core-features.md#ip-address-type-detection)**\n\n### CIDR Aggregation \u0026 Route Summarization\n\n```php\n// Aggregate multiple subnets into larger blocks\n$subnets = [\n    IPv4\\SubnetCalculatorFactory::fromCidr('192.168.0.0/24'),\n    IPv4\\SubnetCalculatorFactory::fromCidr('192.168.1.0/24'),\n];\n$aggregated = IPv4\\SubnetCalculatorFactory::aggregate($subnets);\n// Returns: [192.168.0.0/23]\n\n// Summarize to single supernet\n$summary = IPv4\\SubnetCalculatorFactory::summarize($subnets);\n// Returns: 192.168.0.0/23\n```\n\n**[CIDR Aggregation Guide →](docs/advanced-features.md#cidr-aggregation-and-supernetting)**\n\n### Subnet Exclusion (IPAM)\n\n```php\n// Allocate a /24 but reserve the first /26 for infrastructure\n$allocated = IPv4\\SubnetCalculatorFactory::fromCidr('192.168.1.0/24');\n$reserved  = IPv4\\SubnetCalculatorFactory::fromCidr('192.168.1.0/26');\n\n$available = $allocated-\u003eexclude($reserved);\n// Returns: [192.168.1.64/26, 192.168.1.128/25]\n\n// Exclude multiple subnets\n$available = $allocated-\u003eexcludeAll([$reserved1, $reserved2, $reserved3]);\n```\n\n**[Subnet Exclusion Guide →](docs/advanced-features.md#subnet-exclusion-and-difference-operations)**\n\n### Utilization \u0026 Capacity Planning\n\n```php\n$subnet = IPv4\\SubnetCalculatorFactory::fromCidr('192.168.1.0/24');\n\n// Analyze utilization for host requirements\n$utilization = $subnet-\u003egetUtilizationForHosts(100);  // 39.37%\n$wasted = $subnet-\u003egetWastedAddresses(100);           // 154\n\n// Find optimal subnet size\n$optimalPrefix = IPv4\\SubnetCalculatorFactory::optimalPrefixForHosts(100);\n// Returns: 25 (a /25 provides 126 usable hosts)\n```\n\n**[Utilization Analysis Guide →](docs/advanced-features.md#utilization-statistics)**\n\n### Subnet Operations\n\n```php\n$subnet = IPv4\\SubnetCalculatorFactory::fromCidr('192.168.112.0/23');\n\n// Split into smaller subnets\n$smaller = $subnet-\u003esplit(25);  // Split /23 into /25 subnets\n\n// Navigate to adjacent subnets\n$next = $subnet-\u003egetNextSubnet();       // 192.168.114.0/23\n$prev = $subnet-\u003egetPreviousSubnet();   // 192.168.110.0/23\n```\n\n**[Subnet Operations Guide →](docs/core-features.md#subnet-operations)**\n\n### Generate Reports\n\n```php\n$subnet = IPv4\\SubnetCalculatorFactory::fromCidr('192.168.112.203/23');\n\n// Print formatted report\n$subnet-\u003eprintSubnetReport();\n\n// Get as JSON\n$json = $subnet-\u003egetSubnetJsonReport();\n\n// Get as array\n$array = $subnet-\u003egetSubnetArrayReport();\n\n// Get as string\n$report = $subnet-\u003egetPrintableReport();\n```\n\n**Example Report Output:**\n```\n192.168.112.203/23           Quads      Hex                           Binary    Integer\n------------------ --------------- -------- -------------------------------- ----------\nIP Address:        192.168.112.203 C0A870CB 11000000101010000111000011001011 3232264395\nSubnet Mask:         255.255.254.0 FFFFFE00 11111111111111111111111000000000 4294966784\nNetwork Portion:     192.168.112.0 C0A87000 11000000101010000111000000000000 3232264192\n\nIP Address Type:             private\nNumber of IP Addresses:      512\nNumber of Addressable Hosts: 510\nIP Address Range:            192.168.112.0 - 192.168.113.255\n```\n\n**[Complete Report Documentation →](docs/reports.md)**\n\nDocumentation\n-------------\n\n### Getting Started\n- **[Installation \u0026 Setup](docs/getting-started.md)** - Get up and running quickly\n- **[Creating Subnet Calculators](docs/getting-started.md#creating-subnet-calculators)** - All factory methods\n- **[Basic Usage Examples](docs/getting-started.md#basic-network-information)** - Common operations\n\n### Core Features\n- **[Network Component Access](docs/core-features.md#network-component-access)** - IP addresses, masks, network/host portions\n- **[Network Overlap \u0026 Containment](docs/core-features.md#network-overlap-and-containment)** - Conflict detection\n- **[IP Address Type Detection](docs/core-features.md#ip-address-type-detection)** - Classify addresses (private, public, etc.)\n- **[Subnet Operations](docs/core-features.md#subnet-operations)** - Split, navigate, reverse DNS\n- **[Adjacent Subnet Navigation](docs/core-features.md#adjacent-subnet-navigation)** - Sequential subnet allocation\n\n### Advanced Features\n- **[Subnet Exclusion](docs/advanced-features.md#subnet-exclusion-and-difference-operations)** - IPAM and address carving\n- **[CIDR Aggregation](docs/advanced-features.md#cidr-aggregation-and-supernetting)** - Route summarization\n- **[Utilization Statistics](docs/advanced-features.md#utilization-statistics)** - Capacity planning\n- **[Network Classes](docs/advanced-features.md#network-class-information-legacy)** - Legacy classful networking\n\n### Reference \u0026 Examples\n- **[API Reference](docs/api-reference.md)** - Complete method documentation\n- **[Reports](docs/reports.md)** - All output formats and examples\n- **[Real-World Examples](docs/examples.md)** - IPAM, firewall rules, BGP, DHCP, DNS, automation\n\n### Quick Links\n- **[Documentation Index](docs/)** - Complete navigation and learning paths\n- **[Quick Reference](docs/README.md#quick-reference)** - Common operations at a glance\n\nUnit Tests\n----------\n\n```bash\ncd tests\nphpunit\n```\n\n[![Coverage Status](https://coveralls.io/repos/github/markrogoyski/ipv4-subnet-calculator-php/badge.svg?branch=master)](https://coveralls.io/github/markrogoyski/ipv4-subnet-calculator-php?branch=master)\n\nStandards\n---------\n\nIPv4 Subnet Calculator (PHP) conforms to the following standards:\n\n * PSR-1 - Basic coding standard (http://www.php-fig.org/psr/psr-1/)\n * PSR-4 - Autoloader (http://www.php-fig.org/psr/psr-4/)\n * PSR-12 - Extended coding style guide (http://www.php-fig.org/psr/psr-12/)\n\nLicense\n-------\n\nIPv4 Subnet Calculator (PHP) is licensed under the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarkrogoyski%2Fipv4-subnet-calculator-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarkrogoyski%2Fipv4-subnet-calculator-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarkrogoyski%2Fipv4-subnet-calculator-php/lists"}