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
Requires
- php: ^8.0.2
Requires (Dev)
- elastic/apm-agent: *
- laravel/framework: ^9.19
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
andqueue:listen
- Job Process in Job Transaction
- Controller Process in Request Transaction
Installation
1. Install Elastic APM PHP Agent
Debian 11
- Install Elastic APM PHP Agent according to the instructions at
https://www.elastic.co/guide/en/apm/agent/php/1.x/setup.html
- Configure APM PHP Agent until it appears in
phpinfo()
(PHP FPM) and also appears inphp --ini
(PHP Cli) - Make sure the configuration works using Kibana (which is connected to the Elastic APM Server) on the
Observability - APM
menu where theelastic_apm.service_name
value in the php ini file is shown as a ServiceDocker
- Use unpad-nginx-php8.1 Docker Image with version 1.1+
- Make sure to use this Environments below to running the docker container
Env | Value | Description |
---|---|---|
APM_ENABLED | true | Elastic APM PHP Agent Status |
APM_SERVER_URL | http://elastic-apm-host:8200 | URL for Elastic APM server |
APM_SERVICE_NAME | App Name | The application name |
- Make sure the docker environments works using Kibana (which is connected to the Elastic APM Server) on the
Observability - APM
menu where theAPM_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];
}