biscolab/laravel-updown

UpDown.io package for Laravel 5

v1.0.0 2019-02-28 21:54 UTC

This package is auto-updated.

Last update: 2024-10-29 04:14:50 UTC


README

UpDown.io package for Laravel 5

Build Status Scrutinizer Code Quality Code Coverage Build Status Packagist Packagist

Installation

You can install the package via composer:

composer require biscolab/laravel-updown:^1.0

Laravel 5.5 (or greater) uses package auto-discovery, so doesn't require you to manually add the Service Provider, but if you don't use auto-discovery UpDownServiceProvider must be registered in config/app.php: The service provider must be registered in config/app.php:

'providers' => [
    ...
    Biscolab\LaravelUpDown\UpDownServiceProvider::class,
];

You can use the facade for shorter code. Add "UpDown" to your aliases:

'aliases' => [
    ...
    'UpDown' => Biscolab\LaravelUpDown\Facades\UpDown::class,
];

Configuration

Add your API Keys

Open .env file and set UPDOWN_API_KEY:

UPDOWN_API_KEY=<YOUR_UPDOWN_API_KEY>

now refresh Laravel cache

php artisan config:cache

You can also create config/updown.php configuration file using:

php artisan vendor:publish --provider="Biscolab\LaravelUpDown\UpDownServiceProvider"

Open config/updown.php configuration file and set api_key if you do not want to set it in .env file:

return [
    'api_key' => env('UPDOWN_API_KEY', ''),       
];

Further info about updown.io service here

How to use

This package uses biscolab/updown-php-sdk. First of all I suggest you to become familiar with that here and with updown.io official documentation

Helper

updown();

updown() helper returns an UpDownBuilder instance containing yhe UpDown object created with your `UPDOWN_API_KEY

Use objects

To call objects you just have to call the homonymous method:

// List all Checks: returns a Checks collection
// Empty Check instance
$checks = updown()->Check()->all();

// Check instance initialized with "xxxx" token
$check = updown()->Check("xxxx");

// Check instance initialized with $params array
// using Biscolab\UpDown\Fields\CheckFields
$params = [
    CheckFields::URL => 'https://insert.your-url.to/check'
];
$check = updown()->Check($params);

Further info about Check class and all af its methods here

Follow the same pattern for Node, WebHook, Event objects.

Test

composer test