PHP Classes

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    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 81 This week: 1All time: 10,067 This week: 560Up
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: 8 packages by
Country: Czech Republic Czech Republic
Age: ???
All time rank: 297932 in Czech Republic Czech Republic
Week rank: 411 Up4 in Czech Republic Czech Republic Up
Innovation award
Innovation award
Nominee: 2x

Documentation

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:81
This week:1
All time:10,067
This week:560Up