PHP code example of dockcodes / dock-thor

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

    

dockcodes / dock-thor example snippets



use function Dock\Thor\init;

init([
    'dsn' => 'YOUR_DSN',
    'environment' => 'production',
]);

use function Dock\Thor\captureMessage;

captureMessage('Something happened');

captureMessage('Cache cleared', Severity::info());


use function Dock\Thor\captureException;

try {
    riskyOperation();
} catch (\Throwable $e) {
    captureException($e);
}

use function Dock\Thor\captureEvent;

$event = new Event();
$event->setMessage('Custom event');

captureEvent($event);
Capturing Last Error

use function Dock\Thor\captureLastError;

captureLastError();

use function Dock\Thor\addBreadcrumb;

addBreadcrumb(new Breadcrumb(
Breadcrumb::LEVEL_INFO,
    'auth',
    'User logged in'
));

use function Dock\Thor\configureScope;

configureScope(function ($scope) {
    $scope->setTag('feature', 'payments');
});

use function Dock\Thor\withScope;

withScope(function ($scope) {
    $scope->setTag('operation', 'import');
});

use function Dock\Thor\startTransaction;
use Dock\Thor\Tracing\TransactionContext;

$context = new TransactionContext();
$context->setName('order-processing');

$transaction = startTransaction($context);