PHP code example of shellrent / kraken-client

1. Go to this page and download the library: Download shellrent/kraken-client 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/ */

    

shellrent / kraken-client example snippets


$report = new \Shellrent\KrakenClient\ReportBuilder( 
  'report-type', //Corresponds to the type code configured on the project on kRAKEN app
  'message' //Message to send
);

$client = new \Shellrent\KrakenClient\KrakenClient( 
  'https://kraken-endpoint.com', //kRAKEN endpoint 
  'auth-token' //Create an "environment" on the project page on kRAKEN app
);

$client->sendReport( $report->getData() );

try {
    /* code that throws an exception */
    
} catch( Exception $exception ) {
    $report = new \Shellrent\KrakenClient\ReportBuilder::createFromException( $exception );
    
    /* send the report */
}

$app->singleton(
    Illuminate\Contracts\Debug\ExceptionHandler::class,
    \Shellrent\KrakenClient\Laravel\KrakenExceptionHandler::class
);

use Shellrent\KrakenClient\Laravel\Facades\KrakenLogger;

KrakenLogger::debug( 'message' );
KrakenLogger::info( 'message' );
KrakenLogger::notice( 'message' );
KrakenLogger::warning( 'message' );
KrakenLogger::error( 'message' );
KrakenLogger::critical( 'message' );
KrakenLogger::alert( 'message' );
KrakenLogger::emergency( 'message' );
 
/******/
'channels' => [
    /*****/
        'stack' => [
            'driver' => 'stack',
            'channels' => ['daily', 'kraken'],
            'ignore_exceptions' => false,
        ],
        /*****/
        'kraken' => [
            'driver' => 'kraken',
            'level' => env('LOG_LEVEL', 'debug'),
            'report_exceptions' => false,
        ],
    /*****/
]

$envs = ['production'];
$krakenHandler = \Shellrent\KrakenClient\Phalcon\KrakenExceptionHandler::create( $envs )
$krakenHandler->report( $exception, $errno, $errstr, $errfile, $errline, $backtrace );

$krakenHandler->addSessionKey( 'logged-used' );

$krakenHandler->addHideDataKey( getenv( 'DATABASE_PASSWORD' ) );
$krakenHandler->addHideDataKey( 'KEY_CLI_ACCESS' );

$logger = \Shellrent\KrakenClient\Phalcon\KrakenService::logger();

$logger->debug( 'message' );
$logger->info( 'message' );
$logger->notice( 'message' );
$logger->warning( 'message' );
$logger->error( 'message' );
$logger->critical( 'message' );
$logger->alert( 'message' );
$logger->emergency( 'message' );

abstract class GenericApplication {
  /******/
  
  private function registerServices() {
      /******/
      $config = \Shellrent\KrakenClient\Phalcon\Config\Config::default();
      \Shellrent\KrakenClient\Phalcon\KrakenService::create( $config )->inject( $this->Di );
  } 
}
bash
php artisan kraken:test
bash
php artisan vendor:publish --provider="Shellrent\KrakenClient\Laravel\KrakenServiceProvider"