PHP code example of bugboard / sdk
1. Go to this page and download the library: Download bugboard/sdk 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/ */
bugboard / sdk example snippets
use BugBoard\Laravel\Facades\BugBoard;
try {
$payments->charge($order);
} catch (\Throwable $e) {
BugBoard::criticalHigh('Payment failed', $e, ['payment', 'backend']);
}
use BugBoard\Laravel\Facades\BugBoard;
BugBoard::major('Checkout is slow'); // a title is all you need
BugBoard::critical('Payment failed', $e); // attach the caught Throwable
BugBoard::critical('Payment failed', $e, ['payments', 'checkout']);
use BugBoard\Client as BugBoardClient;
public function store(Request $request, BugBoardClient $bugboard)
{
$bugboard->moderate('Slow image upload', null, 'uploads');
}
> return [
> App\Providers\AppServiceProvider::class,
> BugBoard\Laravel\BugBoardServiceProvider::class,
> ];
>
// config/bugboard.php
'before_send' => function (array $payload): ?array {
$payload['description'] = preg_replace('/\S+@\S+/', '[email]', $payload['description'] ?? '') ?: null;
return $payload; // or return null to drop the report
},
// bootstrap/app.php (Laravel 11+)
->withExceptions(function (Exceptions $exceptions) {
$exceptions->report(function (\Throwable $e) {
\BugBoard\Laravel\Facades\BugBoard::critical($e->getMessage() ?: $e::class, $e);
});
})
// config/bundles.php
return [
// …
BugBoard\Symfony\BugBoardBundle::class => ['all' => true],
];
use BugBoard\Client as BugBoardClient;
public function __construct(private readonly BugBoardClient $bugboard) {}
$this->bugboard->major('Checkout is slow', $exception, ['checkout']);
use BugBoard\ClientBuilder;
use BugBoard\Config;
$bugboard = ClientBuilder::create(new Config(
keyId: getenv('BUGBOARD_KEY_ID') ?: null,
signingSecret: getenv('BUGBOARD_SIGNING_SECRET') ?: null,
environment: 'production',
));
$bugboard->minor('Tooltip misaligned', null, 'ui,polish');
$bugboard->flush(); // optional — the shutdown hook flushes automatically
$bugboard = ClientBuilder::createFromArray([
'key_id' => getenv('BUGBOARD_KEY_ID') ?: null,
'signing_secret' => getenv('BUGBOARD_SIGNING_SECRET') ?: null,
'environment' => 'production',
'sample_rate' => 0.5,
]);
BugBoard::critical('Validation failed', $request);
BugBoard::major('Bad cart state', ['user_id' => $user->id, 'items' => $cart->items]);
new Config(
keyId: …,
signingSecret: …,
beforeSend: function (array $payload): ?array {
$payload['description'] = preg_replace('/\S+@\S+/', '[email]', $payload['description'] ?? '') ?: null;
return $payload; // or return null to drop the report
},
);
use BugBoard\Client;
use BugBoard\Config;
use BugBoard\Payload;
use BugBoard\TransportInterface;
$transport = new class implements TransportInterface
{
/** @var list<Payload> */
public array $sent = [];
public function send(Payload $payload): void
{
$this->sent[] = $payload;
}
};
$bugboard = new Client(new Config(keyId: 'bbk_test', signingSecret: 'bb_sec_test'), $transport);
$bugboard->critical('Payment failed');
$bugboard->flush();
// $transport->sent[0]->severity === 'critical'
bash
sudo dnf install php-sodium
bash
brew install php
ini
extension=sodium
bash
sudo systemctl restart php8.3-fpm # PHP-FPM
sudo systemctl restart apache2 # mod_php
bash
php -r '
$keypair = sodium_crypto_box_keypair();
$sealed = sodium_crypto_box_seal("hello", sodium_crypto_box_publickey($keypair));
echo sodium_crypto_box_seal_open($sealed, $keypair), PHP_EOL;
'
bash
php artisan vendor:publish --tag=bugboard-config