PHP code example of dotink / slashtrace

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

    

dotink / slashtrace example snippets


   use SlashTrace\SlashTrace;
   use SlashTrace\EventHandler\DebugHandler;

   $slashtrace = new SlashTrace();
   $slashtrace->addHandler(new DebugHandler());

   // Register the error and exception handlers
   $slashtrace->register();
   

   try {
       // Your code
   } catch (Exception $exception) {
       $slashtrace->handleException($exception);
   }
   

use SlashTrace\Context\User;

$user = new User();
$user->setId(12345); 
$user->setEmail('[email protected]');
$user->setName('Philip J. Fry');

$slashtrace->addUser($user);

$slashtrace->recordBreadcrumb("Router loaded");
$slashtrace->recordBreadcrumb("Matched route", [
    "controller" => "orders",
    "action" => "confirm",
]);

$slashtrace->setRelease("1.0.0"); // <- Your version number, commit hash, etc.

use SlashTrace\EventHandler\DebugHandler;
use SlashTrace\DebugRenderer\DebugJsonRenderer;

$handler = new DebugHandler();
$handler->setRenderer(new DebugJsonRenderer());

$slashtrace->addHandler($handler);