PHP code example of pantree / pantree-php
1. Go to this page and download the library: Download pantree/pantree-php 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/ */
pantree / pantree-php example snippets
use Pantree\PantreeClient;
$pantree = PantreeClient::fromDsn($_ENV['PANTREE_DSN']);
try {
riskyOperation();
} catch (\Throwable $e) {
$pantree->captureException($e);
throw $e;
}
use Pantree\Laravel\Pantree;
Pantree::captureException($e);
Pantree::captureMessage('Something notable happened', 'warning');
Pantree::sendHealthReport();
$pantree = PantreeClient::fromDsn(
dsn: $_ENV['PANTREE_DSN'],
environment: 'production', // optional, default 'production'
debug: false, // optional, logs to error_log
);
$pantree = new PantreeClient(
endpoint: 'https://your-pantree.com/api/ingest',
projectKey: 'pk_abc123',
ingestSecret: 'sk_xyz789',
environment: 'production',
debug: false,
);
// Raw PHP
$pantree->captureException($e);
$pantree->captureException($e, [
'user' => ['id' => $userId, 'email' => $email],
'context' => ['orderId' => $orderId],
]);
// Laravel
Pantree::captureException($e);
Pantree::captureException($e, [
'user' => ['id' => auth()->id(), 'email' => auth()->user()?->email],
'context' => ['orderId' => $order->id],
]);
// Raw PHP
$pantree->captureMessage('Slow query detected', 'warning', [
'context' => ['queryMs' => 4200],
]);
// Laravel
Pantree::captureMessage('Queue backlog is growing', 'warning', [
'context' => ['depth' => 3200],
]);
$pantree->send([
'title' => 'Payment timeout',
'message' => 'Stripe API did not respond within 10 s',
'stack' => (new \Exception)->getTraceAsString(),
'level' => 'error',
'runtime' => 'php-cli',
'environment' => 'production',
'user' => ['id' => 42],
'context' => ['provider' => 'stripe'],
]);
// cron-health.php
eeClient;
$pantree = PantreeClient::fromDsn($_ENV['PANTREE_DSN']);
$result = $pantree->sendHealthReport();
echo $result['status'] === 200 ? "OK\n" : "Failed\n";
bash
composer bash
php artisan vendor:publish --tag=pantree-config
src/
PantreeClient.php ← core client (raw PHP + base for Laravel)
Laravel/
Pantree.php ← static facade wrapper (Laravel only)
PantreeServiceProvider.php ← auto-discovery, exception wiring, scheduler
config/
pantree.php ← Laravel config (published via artisan)
examples/
basic-usage.php ← raw PHP usage
health-report.php ← raw PHP cron health script
laravel-exception-handler.php ← custom Laravel exception handler
laravel-health-command.php ← custom Artisan health command
docs/
api-reference.md
getting-started.md
health-reporting.md