Basic useful Server Uptime and connection checker tool., (*1)
, (*2)
Installation
You can install the package via composer:, (*3)
composer require kaankilic/serverup
or require the tool in your composer.json file., (*4)
"kaankilic/serverup": "^2.0"
then run composer install command from your command line., (*5)
Once ServerUp is installed you need to register the service provider.Open up config/app.php and add the provider key of tool., (*6)
'providers' => array(
...
Kaankilic\ServerUp\Providers\ServerUpServiceProvider::class,
)
After that, you need to register the facade in the aliases key of your config/app.php file., (*7)
'aliases' => array(
... aliases
'ServerUp'=> Kaankilic\ServerUp\Facades\ServerUp::class,
)
Finally, from the command line again, publish the default configuration file:, (*8)
php artisan vendor:publish --provider="Kaankilic\ServerUp\Providers\ServerUpServiceProvider"
Usage
Simple Usage, (*9)
ServerUp::ping("http://facebook.com",80);
ServerUp::getIsTotalyAvail(); //returns boolean value
Advanced Usage, (*10)
You must define Hostname and Port values for the ping values.Then, you can get availibility of ip or domain with ping() facades. Example code is on the below:, (*11)
ServerUp::setHostname("http://facebook.com");
ServerUp::setPort(80);
ServerUp::setSampleAmount(50);
ServerUp::setTimeoutDuration(10); // unit is integer based milliseconds
ServerUp::getIsTotalyAvail(); //returns boolean value
var_dump(ServerUp::ping()); //returns the SocketResponses for each ping request