2017 © Pedro Peláez
 

library ip

PHP class to get user IP.

image

josantonius/ip

PHP class to get user IP.

  • PHP
  • 5 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 9 Versions
  • 4 % Grown

The README.md

PHP Ip library

Latest Stable Version License, (*1)

Versión en español, (*2)

PHP class to get user IP., (*3)

After reviewing the code after a few years, I would not recommend the use of the class for a production site, as preference was given to headers easily manipulated by the user to get the IP., (*4)

If the reliability of the header from which the IP will be obtained is not guaranteed, it is better to use $_SERVER['REMOTE_ADDR'] directly or develop a custom solution., (*5)



Requirements

This library is supported by PHP versions 5.6 or higher and is compatible with HHVM versions 3.0 or higher., (*6)

Installation

The preferred way to install this extension is through Composer., (*7)

To install PHP Ip library, simply:, (*8)

composer require Josantonius/Ip

The previous command will only install the necessary files, if you prefer to download the entire source code you can use:, (*9)

composer require Josantonius/Ip --prefer-source

You can also clone the complete repository with Git:, (*10)

$ git clone https://github.com/Josantonius/PHP-Ip.git, (*11)

Or install it manually:, (*12)

Download Ip.php:, (*13)

wget https://raw.githubusercontent.com/Josantonius/PHP-Ip/master/src/Ip.php

Available Methods

Available methods in this library:, (*14)

- Get user's IP

Ip::get();

# Return (string|false) → user IP or false, (*15)

- Validate IP

Ip::validate($ip);
Attribute Description Type Required Default
$ip IP address to be validated. string Yes

# Return (boolean), (*16)

Quick Start

To use this library with Composer:, (*17)

require __DIR__ . '/vendor/autoload.php';

use Josantonius\Ip\Ip;

Or If you installed it manually, use it:, (*18)

require_once __DIR__ . '/Ip.php';

use Josantonius\Ip\Ip;

Usage

Example of use for this library:, (*19)

- Get user's IP

Ip::get();

- Validate IP

$ip = Ip::get();

Ip::validate($ip);

Tests

To run tests you just need composer and to execute the following:, (*20)

git clone https://github.com/Josantonius/PHP-Ip.git

cd PHP-Ip

composer install

Run unit tests with PHPUnit:, (*21)

composer phpunit

Run PSR2 code standard tests with PHPCS:, (*22)

composer phpcs

Run PHP Mess Detector tests to detect inconsistencies in code style:, (*23)

composer phpmd

Run all previous tests:, (*24)

composer tests

If this project helps you to reduce your development time, you can sponsor me to support my open source work :blush:, (*25)

License

This repository is licensed under the MIT License., (*26)

Copyright © 2017-2022, Josantonius, (*27)

The Versions

06/01 2018

dev-master

9999999-dev

PHP class to get user IP.

  Sources   Download

MIT

The Requires

  • php ^5.6 || ^7.0

 

The Development Requires

php ip hhvm remote_addr get user ip

06/01 2018

1.1.7

1.1.7.0

PHP class to get user IP.

  Sources   Download

MIT

The Requires

  • php ^5.6 || ^7.0

 

The Development Requires

php ip hhvm remote_addr get user ip

12/11 2017

1.1.6

1.1.6.0

PHP class to get user IP.

  Sources   Download

MIT

The Requires

  • php ^5.6 || ^7.0

 

The Development Requires

php ip hhvm remote_addr get user ip

01/11 2017

1.1.5

1.1.5.0

PHP class to get user IP.

  Sources   Download

MIT

The Requires

  • php ^5.6 || ^7.0

 

The Development Requires

php ip hhvm remote_addr get user ip

14/10 2017

1.1.4

1.1.4.0

PHP class to get user IP.

  Sources   Download

MIT

The Requires

  • php ^5.6 || ^7.0

 

The Development Requires

php ip hhvm remote_addr get user ip

18/07 2017

1.1.3

1.1.3.0

PHP class to get user IP.

  Sources   Download

MIT

The Requires

  • php ^5.6 || ^7.0

 

php ip hhvm remote_addr get user ip

09/07 2017

1.1.2

1.1.2.0

PHP class to get user IP.

  Sources   Download

MIT

The Requires

  • php ^5.6 || ^7.0

 

php ip hhvm remote_addr get user ip

18/03 2017

1.1.1

1.1.1.0

PHP class to get user IP.

  Sources   Download

MIT

The Requires

  • php ^5.6 || ^7.0

 

php ip hhvm remote_addr get user ip

17/01 2017

1.0.0

1.0.0.0

PHP class to get user IP.

  Sources   Download

MIT

The Requires

  • php >=7.0

 

php ip hhvm remote_addr get user ip