PHP IP Address Validation: Validate and normalize IPv4 and IPv6 addresses

Recommend this page to a friend!
  Info   View files Documentation   View files View files (15)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2020-09-03 (27 days ago) RSS 2.0 feedNot yet rated by the usersTotal: 66 This week: 2All time: 9,738 This week: 124Up
Version License PHP version Categories
ip-addresses 1.0.0Custom (specified...5Networking, PHP 5, Parsers
Description Author

This package can be used validate and normalize IPv4 and IPv6 addresses.

It provides a class that can take a string and validate it as an IP address of either v4 ou v6 of the IP protocol.

There is another class that can parse the IP address string and returns a rewritten version of the IP address in a normalized format.

Picture of Matous Nemec
Name: Matous Nemec <contact>
Classes: 3 packages by
Country: Czech Republic Czech Republic
Age: ???
All time rank: 376434 in Czech Republic Czech Republic
Week rank: 96 Up1 in Czech Republic Czech Republic Up
Innovation award
Innovation award
Nominee: 1x

Details

Mesour IP addresses

  • Author
  • IP address normalizer and validator. For IPv4 and IPv6.

Install

  • With Composer

    composer require mesour/ip-addresses

  • Or download source from GitHub

Usage

Usage: Mesour\IpAddresses\IpAddressValidator

Assert::true(IpAddressValidator::isIpV6('2a00:5565:2222:800::200e'));

Assert::true(IpAddressValidator::isIpV4('127.0.0.1'));

Usage: Mesour\IpAddresses\IpAddressNormalizer

Normalize IPv6:

IpAddressNormalizer::normalizeIpV6('2001:db8:800::ff00:42:8329');

// result is: 2001:0db8:0800:0000:0000:ff00:0042:8329

Compress IPv6:

IpAddressNormalizer::compressIpV6('2001:0db8:0800:0000:0000:ff00:0042:8329');

// result is: 2001:db8:800::ff00:42:8329

Tests

  • Run tests: `bin/check-tests`
  • PHP Stan: `bin/check-stan`
  • Code style: `bin/check-cs`
  Files folder image Files  
File Role Description
Files folder imagebin (3 files)
Files folder imagesrc (1 directory)
Files folder imagetests (2 files, 1 directory)
Accessible without login Plain text file .travis.yml Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file license.md Lic. License text
Accessible without login Plain text file phpstan.neon Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation
Accessible without login Plain text file ruleset.xml Data Auxiliary data

  Files folder image Files  /  bin  
File Role Description
  Accessible without login Plain text file check-cs Data Auxiliary data
  Accessible without login Plain text file check-stan Data Auxiliary data
  Accessible without login Plain text file check-tests Data Auxiliary data

  Files folder image Files  /  src  
File Role Description
Files folder imageMesour (1 directory)

  Files folder image Files  /  src  /  Mesour  
File Role Description
Files folder imageIpAddresses (2 files)

  Files folder image Files  /  src  /  Mesour  /  IpAddresses  
File Role Description
  Plain text file IpAddressNormalizer.php Class Class source
  Plain text file IpAddressValidator.php Class Class source

  Files folder image Files  /  tests  
File Role Description
Files folder imageMesour (1 directory)
  Accessible without login Plain text file bootstrap.php Aux. Auxiliary script
  Accessible without login Plain text file php.ini Data Auxiliary data

  Files folder image Files  /  tests  /  Mesour  
File Role Description
Files folder imageIpAddressesTests (2 files)

  Files folder image Files  /  tests  /  Mesour  /  IpAddressesTests  
File Role Description
  Plain text file BaseTestCase.php Class Class source
  Plain text file IpAddressNormalizerTest.phpt Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:66
This week:2
All time:9,738
This week:124Up

For more information send a message to info at phpclasses dot org.