PHP code example of nikkiii / laravel-cachet

1. Go to this page and download the library: Download nikkiii/laravel-cachet 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/ */

    

nikkiii / laravel-cachet example snippets


use Nikkiii\Cachet\Facades\Cachet;
// you can alias this in config/app.php if you like

// all calls will return either an array if it's a list, or stdClass object if it's data.
// however, ping simply returns a boolean.

// this'll return a list of components registered in cachet!
Cachet::components();

// this'll return the component data for component 1
Cachet::component(1);

// this'll return a list of incidents
Cachet::incidents();

use Nikkiii\Cachet\Facades\Cachet;

// the alternative connection is the other example provided in the default config
Cachet::connection('alternative')->components();

use Nikkiii\Cachet\Facades\Cachet;

// writing this:
Cachet::connection('main')->components();

// is identical to writing this:
Cachet::components();

// and is also identical to writing this:
Cachet::connection()->components();

// this is because the main connection is configured to be the default
Cachet::getDefaultConnection(); // this will return main

// we can change the default connection
Cachet::setDefaultConnection('alternative'); // the default is now alternative

use Nikkiii\Cachet\CachetManager;
use Illuminate\Support\Facades\App; // you probably have this aliased already

class Foo {
    protected $cachet;

    public function __construct(CachetManager $cachet) {
        $this->cachet = $cachet;
    }

    public function bar() {
        $this->cachet->components();
    }
}

App::make('Foo')->bar();
bash
$ php artisan vendor:publish