Skip to content

benjamin-smith/php-ipify

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
src
February 23, 2018 12:16
June 11, 2015 18:09
June 11, 2015 18:09
June 11, 2015 18:09
March 14, 2016 22:26
June 11, 2015 18:09
June 11, 2015 18:09
June 11, 2015 18:09

php-ipify

Software License Build Status Quality Score Total Downloads

This library will retrieve your public IP address from ipify's API service, and return it as a string.

This library also has some other nice features you might care about:

  • This library handles exceptions properly, and usage examples below show you how to deal with errors in a foolproof way.
  • This library only makes API requests over HTTPS.

Install

Via Composer

$ composer require benjamin-smith/php-ipify

Usage

echo Ipify\Ip::get();

Or, if your inclined to catch any errors:

try {
    $ip = Ipify\Ip::get();    
} catch (ConnectionError $e) {
    // If you get here, it means you were unable to reach the ipify service,
    // most likely because of a network error on your end.
} catch (ServiceError $e) {
    // If you get here, it means ipify is having issues, so the request
    // couldn't be completed :(
} catch (Exception $e) {
    // Something else happened (non-ipify related).
}

Change log

Please see CHANGELOG for more information what has changed recently.

Testing

$ vendor/bin/phpunit

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email ben@benjaminsmith.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.