PHP code example of aln / speedtest-php

1. Go to this page and download the library: Download aln/speedtest-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

aln / speedtest-php example snippets


$ php -a
Interactive shell

php > est\Speedtest();
php > $speedtest->getServers();
php > $speedtest->getBestServer();
php > $speedtest->download();
php > $speedtest->upload();
php > $results = $speedtest->results();
php > print_r($results);
Aln\Speedtest\Result Object
(
    [latency:protected] => 4.57
    [download:protected] => 47888585.578516
    [upload:protected] => 64841042.860629
    [bytesReceived:protected] => 59881235
    [bytesSent:protected] => 82579808
)

$ php -a
Interactive shell

php > \Config();
php > $config->setCallback(function ($results) { print_r($results); });
php > $speedtest = new Aln\Speedtest\Speedtest($config);
php > $speedtest->getServers();
php > $speedtest->getBestServer();
php > $speedtest->download();
Aln\Speedtest\Result Object
(
    [latency:protected] => 4.40
    [download:protected] => 0
    [upload:protected] =>
    [bytesReceived:protected] => 0
    [bytesSent:protected] => 0
)

// More dump was here ...

Aln\Speedtest\Result Object
(
    [latency:protected] => 4.40
    [download:protected] => 27519752.835724
    [upload:protected] =>
    [bytesReceived:protected] => 37153149
    [bytesSent:protected] => 0
)
bash
composer