2017 © Pedro Peláez
 

library server-ip

a tool to retrieve the server ip addresses

image

gordywills/server-ip

a tool to retrieve the server ip addresses

  • Wednesday, January 18, 2017
  • by gordy.wills
  • Repository
  • 0 Watchers
  • 0 Stars
  • 24 Installations
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

ServerIP

Introduction

This is a little tool I wrote to help with a Raspberry Pi project. It very simply tries to ascertain values for the loacl IPv4, IPv6 and external (either standard) IP Addresses. It then hold them together in a single object as IP objects defined in Leth\PHP-IPAddress., (*1)

This is my very first attempt at putting something in composer, so feed back is welcomed, but be gentle., (*2)

Installation

Using composer is preferred:, (*3)

Commandline: php composer.phar require "gordywills/server-ip":"dev-master", (*4)

composer.json:, (*5)

{
    "require": {
        "gordywills/server-ip": "dev-master"
    }
}

Use

Instantiate a new instance:, (*6)

<?php
$serverIPAddresses = new ServerIP\Addresses();

Then access the address string through the public methods:, (*7)

<?php
echo $serverIPAddresses->getLocalIP4String();

Public Methods

  • public function getLocalIP4()
  • public function getLocalIP6() Under windows always returns loopback addr
  • public function getExternalIP() If no Internet connection available returns local loopback

Get an object representing the IP Address, (*8)

  • public function getLocalIP4String()
  • public function getLocalIP6String()
  • public function getExternalIPString()

Get a string in human readable form, (*9)

  • public function refreshIPs()

Update all the IP addresses in case they have changed since the object was created, (*10)

Example

<?php
//initiate the composer autoload
require 'vendor/autoload.php';

use ServerIP\Addresses;

$serverIPAddresses = new Addresses();

echo $serverIPAddresses->getLocalIP4String();
echo "\n";
echo $serverIPAddresses->getLocalIP6String();
echo "\n";
echo $serverIPAddresses->getExternalIPString();
echo "\n";

The Versions

18/01 2017

dev-master

9999999-dev

a tool to retrieve the server ip addresses

  Sources   Download

MIT

The Requires

 

by Gordy Wills