dev-master
9999999-deva tool to retrieve the server ip addresses
MIT
The Requires
- php ^5.5 || ^7.0
- leth/ip-address 1.1.1
by Gordy Wills
Wallogit.com
2017 © Pedro Peláez
a tool to retrieve the server ip addresses
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)
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"
}
}
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 function getLocalIP4() public function getLocalIP6() Under windows always returns loopback addr public function getExternalIP() If no Internet connection available returns local loopbackGet 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)
<?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";
a tool to retrieve the server ip addresses
MIT