PHP code example of getfaultline / faultline-php

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

    

getfaultline / faultline-php example snippets




\Faultline\init([
    'apiKey' => getenv('FAULTLINE_API_KEY'), // flt_ingest_...
    'environment' => 'production',
    'release' => '[email protected]',
]);

try {
    doRiskyThing();
} catch (\Throwable $e) {
    \Faultline\captureException($e, ['tags' => ['feature' => 'checkout']]);
}

\Faultline\captureMessage('Payment webhook retried', 'warning');

use Faultline\Integrations\Psr15\FaultlineMiddleware;

\Faultline\init(['apiKey' => getenv('FAULTLINE_API_KEY')]);

$app = Slim\Factory\AppFactory::create();
$app->addErrorMiddleware(true, true, true);
$app->add(new FaultlineMiddleware()); // added last, so it runs first and sees the exception

\Faultline\init(['apiKey' => 'flt_ingest_...', 'endpoint' => 'http://localhost:4000']); // local faultline-server
\Faultline\init(['apiKey' => 'flt_ingest_...', 'endpoint' => 'https://faultline.internal.example.com']);
bash
composer 
bash
FAULTLINE_API_KEY=flt_ingest_... FAULTLINE_ENDPOINT=http://localhost:4000 php examples/plain.php
bash
php artisan vendor:publish --tag=faultline-config