Monitoring PHP

With Instana, you can gain end-to-end visibility into your PHP environment. It helps you to quickly identify performance bottlenecks and optimize application performance.

To get started, install the Instana host agent. The agent automatically deploys the PHP sensor and tracer in your environment, which collects real-time metrics and traces that you can view in the Instana UI. For PHP applications running on AWS Fargate, see Monitoring AWS Fargate.

Supported versions

Supported platforms

The PHP sensor supports the following platforms:

  • Linux (x86_64 and aarch64)
  • Windows (x86_64)
  • AWS Fargate (Linux)
  • Kubernetes (Linux)
  • Docker (Linux)
  • Podman (Linux)

Supported PHP versions

The following table shows the versions of PHP that the PHP sensor supports:

PHP version CPU architecture C standard library Zend Thread Safety (ZTS) Support policy Support type
PHP 8.1 - PHP 8.4 aarch64 glibc 2.17+, musl NTS, ZTS 0 day General availability
PHP 7.2 - PHP 8.0 aarch64 glibc 2.17+, musl NTS, ZTS 0 day End-of-life
PHP 8.1 - PHP 8.4 x86-64 glibc 2.12+, musl NTS, ZTS 0 day General availability
PHP 8.1 - PHP 8.4 x86-64 UCRT NTS, ZTS 0 day General availability
PHP 5.3 - PHP 8.0 x86-64 glibc 2.12+, musl NTS, ZTS 0 day End-of-life

Deprecation policy

Instana deprecates minor versions of PHP at their official end-of-life date, then continues to support them for a year. Afterward, old versions of PHP Tracer will still be available, but their maintenance will be suspended. Moving from end-of-life versions is suggested for improved performance and security. For more information, see Supported Versions and Unsupported Branches.

The original announcement is available at Deprecated and removed features.

Supported PHP SAPIs

The following table shows the PHP Server Application Programming Interface (SAPIs) that the PHP sensor supports for configuration data, metrics, and tracing:

SAPI Support type Operating Systems (OS)
Apache2 with mod_php General availability Linux, Windows
CLI Experimental Linux
PHP-CGI General availability Linux, Windows
PHP-FPM General availability Linux
PHP-FCGI with IIS General availability Windows

Instana can provide tracing for CLI if you configure the tracing extension with the flag instana.enable_cli = 1 that is set in zzz-instana-extras.ini file, which is described in the PHP tracing extension. However, because CLI requests are usually of short duration, Instana cannot connect them to the Dynamic Graph. Therefore, you can see the trace, but you cannot obtain any information about the connected services or infrastructure. Also, you must install the tracing extension. For more information, see the PHP tracing extension. You might need to create zzz-instana.ini file manually for PHP-CLI. For support with setting up CLI tracing, contact IBM support.

Supported composer packages

The following table shows the composer packages that the PHP sensor supports:

Package name Support policy Supported versions
cakephp/cakephp On demand 3.10.5, 4.3.11, 4.5.6, and 5.0.9
couchbase/couchbase 45-days 4.2.2
drupal/core 45 days 8.9.20, 9.5.11, and 10.2.5
elasticsearch/elasticsearch 45 days v6.7.2, v7.11.0, v7.17.2, and v8.14.0
google/cloud-pubsub 45 days v1.41.1 and v1.51
johnpbloch/wordpress 45 days 6.5.2
laminas/laminas-mvc 45 days 3.1.1, 3.3.5, 3.6.1, and 3.7.0
laravel/framework 45-days v10.48.14, v11.11.1, v5.5.50, v5.8.38, v7.30.6, v8.83.27, and v9.52.16
monolog/monolog 45 days 1.27.1, 2.9.3, and 3.6.0
neos/flow On demand 5.3.28, 6.3.21, 7.3.19, and 8.3.9
php-amqplib/php-amqplib 45 days v3.0.0, v3.5.4, and v3.6.2
predis/predis 45 days v1.1.10 and v2.2.2
ruflin/elastica 45 days 6.2.1, 7.3.2, and 8.0.0
symfony/http-kernel 45 days v3.4.49, v4.4.51, v5.4.40, v6.0.20, v6.4.8, and v7.1.1
twig/twig 45 days v2.12.5, v2.16.0, and v3.10.3
yiisoft/yii2 On demand 2.0.50
zendframework/zendframework Deprecated 3.0.0

Supported PHP built-in extensions

PHP Tracer supports tracing forked processes by using PCNTL. When a call to pcntl_fork is detected, a dedicated span is created, and the forked process is instrumented.

Supported PHP extensions

The following table shows the PHP extensions that the PHP sensor supports:

Package name Support policy Supported versions
amqp 45 days 1.11.0 and 2.1.2
cassandra On demand 1.3.2 (Linux only)
couchbase 45 days 2.6.2 and 3.2.2
pecl_http 45 days 3.3.0 and 4.6,2
ibm_db2 45 days 2.1.3 and 2.2.0
memcache On demand 4.0.5.2 and 8.2
memcached On demand 3.2.0 (Linux only)
mongodb 45 days 1.11.1, 1.16.2, 1.19.3, and 1.9.2
oci8 On demand 3.0.0, 3.0.1, and 3.3.0
redis On demand 5.3.7 and 6.0.2
sqlsrv (mssql) On demand 5.12.0

Limitations

Instana doesn't support the following scenarios:

  • PHP on Windows systems with aarch64 architecture
  • PHP running on Windows containers
  • Apache HTTP server configured to serve multiple PHP versions with PHP-CGI or Apache2handler SAPI
  • Multiple tracing tools used simultaneously in PHP, for example, Instana and third-party tracers (such as, New Relic, Dynatrace, or Datadog)
  • PHP runtime with ionCube or SourceGuardian loader extensions and PHP source files encoded with their respective encoder tools.
  • MS SQL instrumentation on Alpine OS with PHP using OpenSSL1.1 is not tested because of a discrepancy with the OpenSSL version used by MSODBC driver.
  • PHP sensor cannot update or uninstall the PHP Tracer if the tracer's debug logging is enabled.

Configuring PHP sensor

The PHP sensor is installed with reasonable defaults for PHP tracing to work automatically when the Instana agent is installed. However, you can configure the sensor through the com.instana.plugin.php section in the agent configuration.yaml file to customize it to work with your PHP runtime.

The following YAML snippet from the agent configuration.yaml file shows the available settings for configuring the PHP sensor:

# PHP Tracing
#com.instana.plugin.php:
#  # Lightweight PHP Tracing. Enabled (true) by default.
#  # PHP tracing is performed by the Instana PHP Tracing extension.
#  tracing:
#    # Enabling tracing (true) will automatically download the Instana PHP Tracing extension
#    # and enable it in the PHP INI configuration.
#    # The PHP runtime will be gracefully restarted if managed by PHP-FPM or Apache
#    # and the extension will be loaded into the PHP runtime. The following PHP runtimes
#    # require a manual restart for the PHP Tracing extension to be loaded into memory:
#    #  - long-running PHP-CGI processes i.e., CGI SAPI
#    #  - pre-forked PHP worker processes
#    #
#    # Disabling tracing (false) will automatically disable the Instana Tracing extension
#    # in the PHP INI configuration. The PHP runtime will be gracefully restarted to
#    # unload the extension from the PHP runtime memory if applicable (see above).
#    # Otherwise, you need to manually restart your PHP runtime to unload the extension.
#    # Disabling tracing implicitly disables profiling.
#    # You can automate the restarts by configuring a custom script. See 'notificationScript'.
#    enabled: true
#    # Whether to install the Instana PHP Tracing extension. Default is true.
#    # When set to false, the Instana PHP Tracing extension will not be enabled in newly
#    # detected PHP runtimes. This setting does not affect the PHP runtimes where
#    # the Instana PHP Tracing extension is already enabled.
#    installExtension: true
#    # The filename to use when querying Apache or PHP-CGI installations for
#    # environment data such as version, architecture, etc. By default, this
#    # is "instana." + Math.random(). + ".php". Uncommenting the setting
#    # below will force a static filename instead.
#    phpInfoFilename: instana.php
#    # Pin the Instana PHP Tracing extension to a specific version.
#    # This can be used to rollback to previous versions of the extension or to test
#    # beta versions (when asked to do so). The version should be provided
#    # in the format major.minory.patch, e.g. 5.1.0
#    # The pinned extension version is automatically installed in the PHP runtime.
#    # See the desciption of 'enabled' flag to know if you need to manually restart
#    # your PHP runtime after pinning the extension version.
#    pinExtensionVersion: x.y.z
#    # The absolute path to an executable shell script (Linux) or powershell script (Windows)
#    # that is to be automatically executed when enabling tracing, pinning extension version
#    # or disabling tracing. You must design this script to restart your PHP runtime so that
#    # the changes made to your PHP INI configuration by the agent are loaded.
#    # Default value is empty.
#    notificationScript: <absolute_path_to_script>
#    # The number of executor threads to use for processing traces. This setting
#    # can be used to fine tune the PHP sensor for specific load environments.
#    # Defaults to the number of available logical processors or 8 (whichever is less).
#    # In general, you don't need to touch this setting unless advised to do so.
#    executorThreads: n
#    # The maximum number of traces the sensor is allowed to keep in the backlog
#    # for processing. Can be used in conjunction with executorThreads to fine tune
#    # the sensor for specific load environments. In general, you don't need to touch
#    # this setting unless advised to do so. Defaults to 1000.
#    executorQueueLimit: 1000
#    # Port on which the sensor is listening for traces. Changing this setting will
#    # not automatically update any .ini files created for the PHP Tracing extension.
#    # In general, you don't need to touch this setting unless advised to do so.
#    # Defaults to port 16816.
#    port: 16816
#    # Whether to remove values in SQL queries to prevent sensitive data from
#    # reaching our backend. This can help to improve agent performance in certain
#    # setups. In general, you don't need to touch this setting unless advised to do so.
#    sanitizeSql: true
 

Enabling automatic restarts

You can change how the PHP sensor attempts to restart your PHP environment through the notificationScript configuration setting. For more information about how to use the notificationScript setting, see the Automatic restarts section.

Configuring PHP-FPM sensor

After you install the Instana agent, the PHP-FPM sensor is automatically installed and configured with defaults.

The following YAML snippet shows the available settings:

#PHP-FPM monitoring
 #com.instana.plugin.phpfpm:
 #  # Enabled (true) by default. Update it to 'false' to disable PHP-FPM discovery and sensor.
 #  enabled: true
 #  monitoring:
 #    # Enabling PHP-FPM worker pool monitoring collects worker pool process metrics like CPU and memory
 #    # usage every second. Enabled (true) by default.
 #    workerPoolMonitoring: true 
 

The PHP-FPM sensor monitors FPM worker pools by default. This monitoring might prevent worker processes from terminating due to the sensor sending automatic status check CGI requests in the background. To avoid this behavior, you can disable worker pool monitoring by setting the workerPoolMonitoring option in the PHP-FPM sensor plugin configuration to false.

Enabling PHP-FPM status page

To thoroughly monitor PHP-FPM metrics, you need to enable the status page. To enable the page, open the worker pool configuration file and add the entry pm.status_path = /status. The Instana PHP-FPM sensor directly accesses the endpoint for the PHP-FPM status page through FastCGI. If the FPM worker pool setting pm.status_listen is defined, the sensor uses it as the endpoint, which configures an invisible worker pool for monitoring the configured FPM worker pools. Otherwise, the sensor defaults to the listen endpoint. To disable the worker monitoring, see Configuring PHP-FPM sensor.

For PHP-FPM that is running inside rootless Podman containers, the listen endpoints of PHP-FPM pools must be accessible from the host through the rootless Podman gateway.

To monitor PHP-FPM metrics on AWS Fargate, you also need to enable the PHP-FPM status page.

Enabling Apache

The Apache configuration must contain the following line:

SetHandler application/x-httpd-php
 

Without the line, the sensor fails to load and the following error message is logged:

> "PHP Sensor is failing because of "NO Version found"
 

Configuring IIS

By default, IIS routes the PHP runtime logs to the PHP webpage, which includes PHP Tracer logs as well. To avoid this behavior, perform one of the following actions:

  • Redirect PHP logs to a different path: To redirect all the PHP logs to a different path, configure the error_log property in the php.ini file .

  • Disable PHP Tracer logs: To disable only PHP Tracer logs, set the environment variable INSTANA_LOG_LEVEL to 0. To set this environment value, complete one of the following steps:

    • Update FastCGI settings for your PHP application

    • Run the following command in the powershell or command prompt terminal:

      PS C:\> C:\Windows\system32\inetsrv\appcmd.exe set config -section:system.webServer/fastCgi /+"[fullPath='<php-cgi executable path>'].environmentVariables.[name='INSTANA_LOG_LEVEL',value='0']" /commit:apphost
       

Viewing metrics

To view metrics for PHP, complete the following steps:

  1. In the sidebar of the Instana UI, select Infrastructure.
  2. Click a specific monitored host.

You can see a host dashboard with all the collected metrics and monitored processes.

Like any other Instana sensor, the PHP sensor does not need any configuration. It automatically detects your PHP installation and collects the following data from the installation:

For PHP, the configuration data, performance metrics, and the health signatures depend on the SAPI used. For more information, see Supported PHP SAPIs.

Configuration data and metrics

The following table lists the generally tracked configuration data:

  • PHP version
  • Server API
  • Zend Thread Safety
  • Loaded Modules
  • Main Ini file
  • Ini directory
  • Additional Ini files parsed
  • PHP extensions directory
Note: The generally tracked configuration for Apache with mod_php is included in the Apache dashboard. For PHP-CGI, this configuration data is included in the used webserver's dashboard (if applicable).

In addition to the generally tracked configuration, the PHP-FPM dashboard includes the following configuration data:

  • Master Process ID
  • Master Configuration
  • Worker Pools

PHP-FPM dashboard also includes the following metrics:

  • Connections
  • Processes
  • Resources

Health signatures

Each sensor has a curated knowledge base of health signatures that are evaluated continuously against the incoming metrics. These health signatures are used to raise issues or incidents that depend on user impact.

Built-in events trigger issues or incidents based on failing health signatures on entities, and custom events trigger issues or incidents based on the thresholds of an individual metric of any specific entity.

For more information about built-events for PHP-FPM, see the Built-in events reference.

Tracing

Instana provides both automatic and manual instrumentation for PHP.

Automatic instrumentation

Instana automatically instruments your PHP applications by using the PHP Tracing extension.

PHP Tracing extension

The PHP tracing extension is automatically downloaded when the PHP sensor is enabled. The configuration for installing the extension is enabled by default in <agent_install_dir>/etc/instana/configuration.yaml . For more information, see Configuring PHP sensor .

PHP tracing is active by default. For more information about disabling tracing, see Disabling the PHP tracing sensor. The PHP sensor is linked to a PHP SAPI sensor. So, tracing starts only when the Instana agent detects a supported SAPI sensor (currently PHP-FPM, mod_php, and php-cgi). For more information, see Supported PHP SAPIs.

The PHP sensor gathers information about the SAPI's configuration and downloads an appropriate Instana extension based on your version of PHP and your host's architecture. The PHP sensor always downloads the most recent version of the Instana extension. However, you can also pin (force) a specific version by setting pinExtensionVersion: x.y.z in the configuration.yaml file.

For more information about the Instana PHP Tracing extension and customizing PHP tracing, see Enabling and configuring PHP tracing:

Manual download of PHP extension

PHP CLI instrumentation requires manual deployment of PHP Instana extension because PHP CLI processes are ephemeral and the PHP sensor cannot discover CLI process reliably. For download instructions, see Manual installation of PHP tracing extension.

Auto-instrumented libraries and frameworks

Instana instruments your PHP application at the PHP engine level and provides the traces for selected function calls.

Databases

The following table lists the databases that PHP Tracer can auto-instrument. It also contains the databases that are supported through generic PHP Data Objects (PDO) extension [1] :

Database Instrumentation identifier [2] Instrumentation flag [3]
Cassandra cassandra NA
Couchbase couchbase 1048576
Elasticsearch elasticsearch NA
IBM Db2 db2 256
LDAP ldap 536870912
Memcache memcache 128
Memcached memcache 128
MongoDB mongodb 32
MS SQL (sqlsrv) mssql 17179869184
Mysql mysql 64
Mysqli mysql 64
OCI8 oci8 512
Redis (with predis or PECL redis) redis 16
CUBRID (PDO) pdo 4
MS SQL Server (PDO) pdo 4
Firebird (PDO) pdo 4
IBM (PDO) pdo 4
Informix (PDO) pdo 4
MySQL (PDO) pdo 4
Oracle (PDO) pdo 4
ODBC and Db2 (PDO) pdo 4
PostgreSQL (PDO) pdo 4
SQLite (PDO) pdo 4
Frameworks

The following table lists the web applications frameworks that PHP Tracer can auto-instrument:

Framework Instrumentation identifier [2:1] Instrumentation flag [3:1]
Laminas laminas 33554432
Laravel laravel 8388608
Symfony symfony 4194304
Wordpress wordpress 32768
Zend Framework zf 33554432
CakePHP [4] NA NA
Messaging

The following table lists the messaging technologies that PHP Tracer can auto-instrument:

Messaging Instrumentation identifier [2:2] Instrumentation flag [3:2]
AMQP (pecl-amqp/pecl-amqp-lib) amqp 65536
Google Cloud Pub/Sub gcpsa 268435456
HTTP Protocols

The following table lists the HTTP protocols-supported PHP libraries that PHP Tracer can auto-instrument:

Protocol Instrumentation identifier [2:3] Instrumentation flag [3:3]
cURL curl 8
HTTP Streams streams 1
PECL HTTP pecl_http 2048
SOAP soap 16384
Logging

The following table lists the logging frameworks that PHP Tracer can auto-instrument:

Logging framework Instrumentation identifier [2:4] Instrumentation flag [3:4]
Drupal logger drupal 67108864
Monolog monolog 1073741824
Yii logger yii 2147483648
Zend_Log zendlog 4294967296
PHP built-in extensions

The following table lists the PHP built-in extensions that PHP Tracer can auto-instrument:

Extension Instrumentation identifier [2:5] Instrumentation flag [3:5]
PCNTL (pcntl_fork) NA NA
Sessions sessions 2
SOAP soap 16384
Templating

The following table lists the template libraries that PHP Tracer can auto-instrument:

Template library Instrumentation identifier [2:6] Instrumentation flag [3:6]
Twig twig 2097152
Blade blade 16777216
Others

The following table lists the widely used PHP functions calls of miscellaneous types which PHP tracer can auto-instrument:

Name Instrumentation identifier [2:7] Instrumentation flag [3:7]
Exceptions exceptions 262144
fastcgi_finish_request NA NA
Shell calls shell 1024
Compile time NA NA
OpCache metrics NA NA
Note: Stack traces in span details are supported by only PHP 5.4 and later versions.

Manual instrumentation

You can also manually instrument your PHP code through tracing SDKs. By using tracing SDKs, you can add tracing data to the traces automatically collected by Instana. PHP provides the following SDKs:

  • PHP SDK
  • OTel SDK Instana exporter
Note: PHP SDK is deprecated and will be removed from Instana effective 30 May 2026. To ensure continued tracing support, use the OTel SDK Instana exporter for manual instrumentation.

PHP-SDK

The PHP tracing extension comes with a minimal SDK. By using this SDK, you can manually instrument your code. For more information, see PHP-SDK.

OTel SDK Instana exporter

Instana provides OTel SDK exporter for manual instrumentation of your code that uses OpenTelemetry. It converts the OpenTelemetry spans into Instana spans before they are exported directly to the Instana agent. For usage details, see Instana exporter.

Integrating with OpenTracing

Instana provides a separate PHP SDK for tracing with OpenTracing. Unlike Instana's own PHP instrumentation, the OpenTracing SDK requires you to manually instrument your code. Traces that are generated through the PHP OpenTracing SDK are separate from traces that are generated by Instana's own tracing.

Note: PHP OpenTracing SDK is supported on Linux operating systems only.

Integrating with OpenTelemetry

Instana supports OpenTelemetry instrumentation for PHP applications. The OpenTelemetry PHP extension has automatic instrumentation capability (also called zero-code instrumentation) that generates traces and exports them to configured endpoints, such as the OpenTelemetry Collector and the backend.

To bring these spans into Instana, you can use one of the following exporters:

The OpenTelemetry traces are visualized in the Instana UI, similar to Instana PHP traces. For more information, see OpenTelemetry Integration for PHP Applications.

Serverless tracing

Instana supports serverless tracing for the AWS Fargate environment. Similar to the Instana native extension, the serverless extension also enables the PHP tracing by default. For more information on configuration details, see Monitoring AWS Fargate.

To enable the serverless tracing, make sure that the following requirements are met:

  • OpenSSL3 or OpenSSL1.1 is installed in the PHP container.
  • INSTANA_ENDPOINT_URL and INSTANA_AGENT_KEY environment variables are available to the PHP. For more information on how to configure these variables, see Configuring task definition.
Note: PHP serverless tracing and native tracing (with Instana agent) cannot work together because, serverless tracer requires OpenSSL dependency, which conflicts with the native tracing implementation.

Profiling

The PHP profiler supports CPU usage profile type and it is available only when the native PHP Tracer is used with the Instana agent. The PHP profiler is not supported in serverless monitoring.

For more information about enabling it, see Configuring profiling.

  1. Instana instruments selected function calls in the generic database PDO extension to capture spans of the corresponding database driver-specific PDO extensions. It does not instrument the database driver-specific PDO extensions directly. Also, Instana does not support the PDO database driver-specific subclasses feature that is introduced in PHP 8.4. ↩︎

  2. The instrumentation identifier is the key that is used in the YAML configuration to enable or disable tracing for a specific library. ↩︎ ↩︎ ↩︎ ↩︎ ↩︎ ↩︎ ↩︎ ↩︎

  3. The instrumentation flag is the bit flag value that is used in the ini settings to disable tracing for a specific library or a set of libraries. ↩︎ ↩︎ ↩︎ ↩︎ ↩︎ ↩︎ ↩︎ ↩︎

  4. Instana instruments only Cake\Error\BaseErrorHandler and Cake\Error\ExceptionTrap classes in the CakePHP framework. ↩︎