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

Recommend this page to a friend!

  Author Author  
Picture of Matous Nemec
Name: Matous Nemec <contact>
Classes: 3 packages by
Country: Czech Republic Czech Republic
Innovation award
Innovation award
Nominee: 1x


  Detailed description   Download Download .zip .tar.gz  
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.

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`

  Classes of Matous Nemec  >  PHP IP Address Validation  >  Download Download .zip .tar.gz  >  Support forum Support forum  >  Blog Blog  >  RSS 1.0 feed RSS 2.0 feed Latest changes  
Name: PHP IP Address Validation
Base name: ip-addresses
Description: Validate and normalize IPv4 and IPv6 addresses
Version: -
PHP version: 5
License: Custom (specified in a license file)
 
  Groups   Applications   Files Files  

  Groups  
Group folder image Networking Networking protocols, clients and servers View top rated classes
Group folder image PHP 5 Classes using PHP 5 specific features View top rated classes
Group folder image Parsers Programming language interpreters and format parsers View top rated classes


  Applications that use this package  
No pages of applications that use this class were specified.

Add link image If you know an application of this package, send a message to the author to add a link here.

  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

Download Download all files: ip-addresses.tar.gz ip-addresses.zip
NOTICE: if you are using a download manager program like 'GetRight', please Login before trying to download this archive.

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