Skip to content
bliptracedocs

Install an SDK

PHP

The framework-free PHP SDK. Use it directly in any PHP app, or as the base the framework adapters build on.

On this page

bliptrace/php builds, scrubs and sends error envelopes with no framework dependency. Every PHP framework adapter (Laravel, Symfony, CakePHP, CodeIgniter, Yii2, Drupal, WordPress) is a thin layer on top of it.

Package bliptrace/php on Packagist, ^1.2
Source github.com/bliptrace/bliptrace-php

Install

composer require bliptrace/php:^1.2

Use it

use G8Scope\Php\Client;
use G8Scope\Php\Config;

$bliptrace = new Client(Config::fromEnv([
    'base_path'  => __DIR__,              // marks your own frames as in-app
    'scrub_keys' => ['password', 'token'],
]));

try {
    // ...
} catch (\Throwable $e) {
    $bliptrace->capture($e, ['user' => ['id' => '123']]);
}

Config::fromEnv() reads the variables below. A variable that is set wins over the array; anything unset keeps the array value, then the default. You can also build the config in code:

$bliptrace = new Client(new Config(
    key: getenv('BLIPTRACE_KEY'),
    endpoint: 'https://ingest.bliptrace.com',
    environment: 'production',
    release: '[email protected]',
    basePath: __DIR__,
    scrubKeys: ['password', 'token'],
    ignoreExceptions: [],
    sampleRate: 1.0,
));
Variable fromArray() key Default
BLIPTRACE_KEY key none
BLIPTRACE_ENDPOINT endpoint legacy host: set https://ingest.bliptrace.com
BLIPTRACE_ENABLED enabled true
BLIPTRACE_ENVIRONMENT environment production
BLIPTRACE_RELEASE release none
BLIPTRACE_SAMPLE_RATE sample_rate 1.0
BLIPTRACE_TIMEOUT timeout 3
BLIPTRACE_MAX_RETRIES max_retries 2
BLIPTRACE_RETRY_BASE_MS retry_base_ms 100
BLIPTRACE_RETRY_CAP_MS retry_cap_ms 2000
BLIPTRACE_MAX_FRAMES max_frames 30
BLIPTRACE_MAX_MESSAGE max_message 2000

Good to know

  • capture() builds, scrubs and sends straight away, and never throws into your app.
  • To avoid blocking a request, build now and send later: $env = $bliptrace->buildEnvelope($e, $context); then $bliptrace->sendEnvelope($env); from a shutdown function.
  • sampleRate drops a random share of events before anything is built. Bliptrace samples again on the server.
  • The default transport is a dependency-free cURL transport. You can swap in your own through the Transport interface.
  • G8Scope\Php\Env::get('KEY') is the same lookup for single values; adapters use it.
  • The old G8SCOPE_* names are still read when the BLIPTRACE_* one is unset, until 2.0.
Documentation