aaronheath/laravel-speed-test

Perform scheduled tests to verify downstream bandwidth.


README

Build Status

Introduction

This is a personal package to facilitate scheduled downstream bandwidth checks.

Installation

This package is installed via Composer.

Before installing, the repository, along with other private packages, must be added to the repositories section of the host projects composer.json.

"repositories": [
    {
        "type": "vcs",
        "url": "https://github.com/aaronheath/laravel-speed-test"
    },
    {
        "type": "vcs",
        "url": "https://github.com/aaronheath/oauth-client"
    },
    {
        "type": "vcs",
        "url": "https://github.com/aaronheath/class-logger"
    }
],

To install, run the following command.

composer require aaronheath/laravel-speed-test

Then, publish the configuration file. New file will be created at config/bandwidth-check.php.

Another new configuration file maybe created for oauth-client. Please refer to that project for further details.

php artisan vendor:publish

Finally, you'll want to configure the bandwidth checker by updating the projects .env file. Update values as required.

BANDWIDTH_CHECK_ENABLED=true
BANDWIDTH_CHECK_REPORT_URL=https://example.com/api/bandwidth-check
BANDWIDTH_CHECK_DOWNLOAD_URL=https://example.com/50MB.file
BANDWIDTH_CHECK_FILESIZE=50

Performing Bandwidth Checks

Via CLI

Once properly configured, bandwidth checks can be performed via cli.

php artisan bandwidth-check:run

By executing this command, a check will be performed and results sent to the remote repository.

Via Job

Bandwidth checks can also be dispatched onto the queue via a job.

dispatch(new Heath\BandwidthCheck\BandwidthCheckJob);

Directly

A bandwidth check can also be actioned synchronously.

(new Heath\BandwidthCheck\BandwidthCheck)->run();

BandwidthCheck also includes a handy isEnabled() method to help ensure that checks are enabled.

(new Heath\BandwidthCheck\BandwidthCheck)->isEnabled(); // bool