{"id":18784150,"url":"https://github.com/kdevelopement/ip-tools","last_synced_at":"2025-12-20T23:30:16.378Z","repository":{"id":60434797,"uuid":"543132997","full_name":"KDevelopement/ip-tools","owner":"KDevelopement","description":null,"archived":false,"fork":false,"pushed_at":"2022-09-29T13:23:19.000Z","size":12,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-29T11:51:42.675Z","etag":null,"topics":[],"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/KDevelopement.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null}},"created_at":"2022-09-29T13:17:30.000Z","updated_at":"2023-12-10T22:40:21.000Z","dependencies_parsed_at":"2022-09-29T14:30:13.121Z","dependency_job_id":null,"html_url":"https://github.com/KDevelopement/ip-tools","commit_stats":null,"previous_names":["klicense/ip-tools","kdevelopement/ip-tools"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KDevelopement%2Fip-tools","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KDevelopement%2Fip-tools/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KDevelopement%2Fip-tools/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KDevelopement%2Fip-tools/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/KDevelopement","download_url":"https://codeload.github.com/KDevelopement/ip-tools/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239699583,"owners_count":19682575,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-11-07T20:42:08.822Z","updated_at":"2025-12-20T23:30:16.075Z","avatar_url":"https://github.com/KDevelopement.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PHP IP Tools\n\n[![Build Status](https://travis-ci.org/k7brasil/php-ip-tools.svg?branch=master)](https://travis-ci.org/k7brasil/php-ip-tools)\n[![Latest Stable Version](https://img.shields.io/packagist/v/kseven/ip-tools.svg)](https://packagist.org/packages/kseven/ip-tools)\n[![Total Downloads](https://img.shields.io/packagist/dt/kseven/ip-tools.svg)](https://packagist.org/packages/kseven/ip-tools)\n[![Downloads Month](https://img.shields.io/packagist/dm/kseven/ip-tools.svg)](https://packagist.org/packages/kseven/ip-tools)\n[![License](https://img.shields.io/packagist/l/kseven/ip-tools.svg)](https://github.com/k7brasil/ip-tools/LICENSE.md)\n\n\nUniversal IP Tools for manipulation on IPv4 and IPv6.\n\n## Require this package with Composer\nInstall this package through [Composer](https://getcomposer.org/).\nEdit your project's `composer.json` file to require\n`kseven/ip-tools`.\n\nCreate *composer.json* file:\n```js\n{\n    \"name\": \"yourproject/yourproject\",\n    \"type\": \"project\",\n    \"require\": {\n        \"kseven/ip-tools\": \"~1.1.0\"\n    }\n}\n```\nAnd run composer update\n\n**Or** run a command in your command line:\n\n```\ncomposer require kseven/ip-tools\n```\n\n## Usage\n```php\n\u003c?php\n    $loader = require __DIR__.'/vendor/autoload.php';\n\n    use KSeven\\IPTools\\Ip;\n\n    // Validating\n    $status = Ip::isValid('192.168.1.1'); // true\n\n    $status = Ip::isValid('192.168.1.256'); // false\n\n\n    // ip2long, long2ip\n\n    /// IPv4\n    $long = Ip::ip2long('192.168.1.1'); // 3232235777\n\n    $dec = Ip::long2ip('3232235777'); // 192.168.1.1\n\n    /// IPv6\n    $long = Ip::ip2long('fe80:0:0:0:202:b3ff:fe1e:8329'); // 338288524927261089654163772891438416681\n\n    $dec = Ip::long2ip('338288524927261089654163772891438416681', true); // fe80::202:b3ff:fe1e:8329\n\n\n    // Matching\n\n    /// IPv4\n    $status = Ip::match('192.168.1.1', '192.168.1.*'); // true\n\n    $status = Ip::match('192.168.1.1', '192.168.*.*'); // true\n\n    $status = Ip::match('192.168.1.1', '192.168.*.*'); // true\n\n    $status = Ip::match('192.168.1.1', '192.168.0.*'); // false\n\n\n    $status = Ip::match('192.168.1.1', '192.168.1/24'); // true\n\n    $status = Ip::match('192.168.1.1', '192.168.1.1/255.255.255.0'); // true\n\n    $status = Ip::match('192.168.1.1', '192.168.0/24'); // false\n\n    $status = Ip::match('192.168.1.1', '192.168.0.0/255.255.255.0'); // false\n\n\n    $status = Ip::match('192.168.1.5', '192.168.1.1-192.168.1.10'); // true\n\n    $status = Ip::match('192.168.5.5', '192.168.1.1-192.168.10.10'); // true\n\n    $status = Ip::match('192.168.5.5', '192.168.6.1-192.168.6.10');\n\n\n    $status = Ip::match('192.168.1.1', array('122.128.123.123', '192.168.1.*', '192.168.123.124')); // true\n\n    $status = Ip::match('192.168.1.1', array('192.168.123.*', '192.168.123.124'));\n\n    /// IPv6\n\n    $status = Ip::match('2001:cdba:0000:0000:0000:0000:3257:9652', '2001:cdba:0000:0000:0000:0000:3257:*'); // true\n\n    $status = Ip::match('2001:cdba:0000:0000:0000:0000:3257:9652', '2001:cdba:0000:0000:0000:0000:*:*'); // true\n\n    $status = Ip::match('2001:cdba:0000:0000:0000:0000:3257:9652',\n                        '2001:cdba:0000:0000:0000:0000:3257:1234-2001:cdba:0000:0000:0000:0000:3257:9999'); // true\n\n\n    $status = Ip::match('2001:cdba:0000:0000:0000:0000:3258:9652', '2001:cdba:0000:0000:0000:0000:3257:*'); // false\n\n    $status = Ip::match('2001:cdba:0000:0000:0000:1234:3258:9652', '2001:cdba:0000:0000:0000:0000:*:*'); // false\n\n    $status = Ip::match('2001:cdba:0000:0000:0000:0000:3257:7778',\n                        '2001:cdba:0000:0000:0000:0000:3257:1234-2001:cdba:0000:0000:0000:0000:3257:7777'); // false\n\n```\n\n\n\n\n-----\nThis code is available on\n[Github](https://github.com/k7brasil/php-ip-tools). Pull requests are welcome.\n\n## Troubleshooting\n\nIf you like living on the edge, please report any bugs you find on the\n[PHP IP Tools issues](https://github.com/k7brasil/php-ip-tools/issues) page.\n\n## Contributing\n\nSee [CONTRIBUTING.md](CONTRIBUTING.md) for information.\n\n## License\n\nPlease see the [LICENSE](LICENSE.md) included in this repository for a full copy of the MIT license,\nwhich this project is licensed under.\n\n## Credits\n\n- [K'Seven](https://github.com/k7brasil)\n\nFull credit list in [CREDITS](CREDITS)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkdevelopement%2Fip-tools","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkdevelopement%2Fip-tools","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkdevelopement%2Fip-tools/lists"}