{"id":42172810,"url":"https://github.com/lifo101/ip","last_synced_at":"2026-01-26T21:32:13.434Z","repository":{"id":8107660,"uuid":"9523092","full_name":"lifo101/ip","owner":"lifo101","description":"IP address helper PHP library for working with IPv4 and IPv6 addresses","archived":false,"fork":false,"pushed_at":"2022-10-05T19:18:53.000Z","size":43,"stargazers_count":18,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-11-21T07:25:02.166Z","etag":null,"topics":["ipv4","ipv6","library","php"],"latest_commit_sha":null,"homepage":null,"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/lifo101.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-04-18T14:07:40.000Z","updated_at":"2023-09-28T09:22:44.000Z","dependencies_parsed_at":"2022-07-17T14:47:10.093Z","dependency_job_id":null,"html_url":"https://github.com/lifo101/ip","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/lifo101/ip","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lifo101%2Fip","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lifo101%2Fip/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lifo101%2Fip/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lifo101%2Fip/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lifo101","download_url":"https://codeload.github.com/lifo101/ip/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lifo101%2Fip/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28788370,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-26T21:13:08.818Z","status":"ssl_error","status_checked_at":"2026-01-26T21:13:08.448Z","response_time":59,"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":["ipv4","ipv6","library","php"],"created_at":"2026-01-26T21:32:12.892Z","updated_at":"2026-01-26T21:32:13.430Z","avatar_url":"https://github.com/lifo101.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"## IP Address Helper Library\n\nIP address helper PHP library for working with IPv4 and IPv6 addresses. Convert any IP address into decimal, hex or binary and back again.\n\n### Notes\n\nThis library is not complete and is missing certain CIDR, Subnet and other miscellaneous IP features. \nMost of the IP conversion routines use `BCMATH` to do calculations which means this library is not the fastest it\ncould be. Once the library is in a more stable state I may start attempting to optimize certain bits.\n\nFeel free to send pull requests with missing functionality.\n\n### Examples\n\nThe translation routines are IP agnostic, meaning they don't care if you pass in an IPv4 or IPv6 address.\nAll IP calculations are done in `Decimal` which is perfect for storing in databases. \n\n```php\nuse Lifo\\IP\\IP;\nuse Lifo\\IP\\CIDR:\n\n// IPv4\necho '127.0.0.1 = ', IP::inet_ptod('127.0.0.1'), \"\\n\";\necho IP::inet_dtop('2130706433'), \" = 2130706433\\n\";\necho '127.0.0.1 = ', IP::inet_ptoh('127.0.0.1'), \" (hex)\\n\";\n\n// IPv6\necho '2001:4056::1 = ', IP::inet_ptod('2001:4056::1'), \"\\n\";\necho IP::inet_dtop('42541793049812452694190522094162280449'), \" = 42541793049812452694190522094162280449\\n\";\necho '2001:4056::1 = ', IP::inet_ptoh('2001:4056::1'), \" (hex)\\n\";\n\n// CIDR \n\n// note: the true CIDR block is calculated from the prefix (the ::1 is ignored)\n$ip = new CIDR('2001:4056::1/96');\n\necho \"$ip\\n\", implode(' - ', $ip-\u003egetRange()), \" (\" . number_format($ip-\u003egetTotal()) . \" hosts)\\n\";\n```\n\n```\n// expected output:\n127.0.0.1 = 2130706433\n127.0.0.1 = 2130706433\n127.0.0.1 = 7f000001 (hex)\n\n2001:4056::1 = 42541793049812452694190522094162280449\n2001:4056::1 = 42541793049812452694190522094162280449\n2001:4056::1 = 20014056000000000000000000000001 (hex)\n\n2001:4056::1/96\n2001:4056:: - 2001:4056::ffff:ffff (4,294,967,296 hosts)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flifo101%2Fip","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flifo101%2Fip","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flifo101%2Fip/lists"}