PHP Classes

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

Recommend this page to a friend!
  Info   Documentation   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 82 All time: 10,080 This week: 146Up
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: 297632 in Czech Republic Czech Republic
Week rank: 66 Up1 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 (15)  
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 (15)  /  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 (15)  /  src  
File Role Description
Files folder imageMesour (1 directory)

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

  Files folder image Files (15)  /  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 (15)  /  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 (15)  /  tests  /  Mesour  
File Role Description
Files folder imageIpAddressesTests (2 files)

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

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:82
This week:0
All time:10,080
This week:146Up