unpad-dev/elastic-apm-php-agent-laravel

Additional Features for Elastic APM PHP Agent when using Laravel 9+ Framework

0.9.0 2023-01-18 18:47 UTC

This package is not auto-updated.

Last update: 2025-06-20 19:34:18 UTC


README

Additional Features for Elastic APM PHP Agent when using Laravel 9+ Framework

Features

  • Artisan Transaction Name with arguments and options
  • Job Transaction for queue:work and queue:listen
  • Job Process in Job Transaction
  • Controller Process in Request Transaction

Installation

1. Install Elastic APM PHP Agent

Debian 11
  1. Install Elastic APM PHP Agent according to the instructions at https://www.elastic.co/guide/en/apm/agent/php/1.x/setup.html
  2. Configure APM PHP Agent until it appears in phpinfo() (PHP FPM) and also appears in php --ini (PHP Cli)
  3. Make sure the configuration works using Kibana (which is connected to the Elastic APM Server) on the Observability - APM menu where the elastic_apm.service_name value in the php ini file is shown as a Service
    Docker
  4. Use unpad-nginx-php8.1 Docker Image with version 1.1+
  5. Make sure to use this Environments below to running the docker container
EnvValueDescription
APM_ENABLEDtrueElastic APM PHP Agent Status
APM_SERVER_URLhttp://elastic-apm-host:8200URL for Elastic APM server
APM_SERVICE_NAMEApp NameThe application name
  1. Make sure the docker environments works using Kibana (which is connected to the Elastic APM Server) on the Observability - APM menu where the APM_SERVICE_NAME value in the container environment is shown as a Service

2. Install Package

Once the PHP APM Elastic Agent is installed, install this package using composer

$ composer require unpad-dev/elastic-apm-php-agent-laravel

Usage for Job Process

Attach Middleware \UnpadDev\ElasticApm\Middleware\JobMiddleware to every Job in the job's middleware method to show Job Process in Elastic APM

use UnpadDev\ElasticApm\Middleware\JobMiddleware;

/**
* Get the middleware the job should pass through.
*
* @return array
*/
public function middleware()
{
    return [new JobMiddleware];
}