PHP code example of zuams / elastic-apm-laravel

1. Go to this page and download the library: Download zuams/elastic-apm-laravel 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/ */

    

zuams / elastic-apm-laravel example snippets


protected $middleware = [
    // ... more middleware
    \Zuams\ElasticApmLaravel\Middleware\RecordTransaction::class,
];

$app->middleware([
    Zuams\ElasticApmLaravel\Middleware\RecordTransaction::class
]);

$app->register(\Zuams\ElasticApmLaravel\Providers\ElasticApmServiceProvider::class);

// Use any normal Laravel method of resolving the dependency
$transaction = app(\Zuams\ElasticApmLaravel\Apm\Transaction::class);

$span = $transaction->startNewSpan('My Span', 'app.component_name');

// do some stuff

$span->end();

ElasticApm::captureThrowable($exception);
ElasticApm::send();

use ElasticApm;
bash
php artisan vendor:publish --tag=config