PHPackages                             solarwinds/apm - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. solarwinds/apm

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

solarwinds/apm
==============

Solarwinds specific OpenTelemetry SDK for PHP

9.0.0-alpha.3(2mo ago)0276↓86.7%2[5 PRs](https://github.com/solarwinds/apm-php/pulls)Apache-2.0PHPPHP ^8.1CI passing

Since Nov 20Pushed 3w ago2 watchersCompare

[ Source](https://github.com/solarwinds/apm-php)[ Packagist](https://packagist.org/packages/solarwinds/apm)[ RSS](/packages/solarwinds-apm/feed)WikiDiscussions main Synced today

READMEChangelog (3)Dependencies (46)Versions (31)Used By (0)

SolarWinds APM PHP Library
==========================

[](#solarwinds-apm-php-library)

[![Packagist Version](https://camo.githubusercontent.com/59f6ad75a1f851d6fa6c6306a81e80f01cabb7e77214c0a42e4106201b6615be/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f736f6c617277696e64732f61706d)](https://camo.githubusercontent.com/59f6ad75a1f851d6fa6c6306a81e80f01cabb7e77214c0a42e4106201b6615be/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f736f6c617277696e64732f61706d)[![Packagist Downloads](https://camo.githubusercontent.com/b4e20d2f4a84fda470c9e29c2e716697353491b50b1e3abdd62f7e52128ffe3d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f736f6c617277696e64732f61706d)](https://camo.githubusercontent.com/b4e20d2f4a84fda470c9e29c2e716697353491b50b1e3abdd62f7e52128ffe3d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f736f6c617277696e64732f61706d)[![PHP CI](https://github.com/solarwinds/apm-php/actions/workflows/php.yml/badge.svg)](https://github.com/solarwinds/apm-php/actions/workflows/php.yml)[![codecov](https://camo.githubusercontent.com/b9bacfb7ac9453d07fbe965feeb70c6575ee318b302d4f358732a22fb30db1bc/68747470733a2f2f636f6465636f762e696f2f6769746875622f736f6c617277696e64732f61706d2d7068702f67726170682f62616467652e7376673f746f6b656e3d6734497a63786d545347)](https://codecov.io/github/solarwinds/apm-php)[![OpenSSF Scorecard](https://camo.githubusercontent.com/cf568f9c89fbfbec42e9af367cd8760cb45329860ad03a6d9ef755f99a14f02c/68747470733a2f2f6170692e73636f7265636172642e6465762f70726f6a656374732f6769746875622e636f6d2f736f6c617277696e64732f61706d2d7068702f6261646765)](https://scorecard.dev/viewer/?uri=github.com/solarwinds/apm-php)[![GitHub License](https://camo.githubusercontent.com/ff6571c1ba0fdee1619a9869e10924726e71e98562d0c50d9d0a6b86e1814e96/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f736f6c617277696e64732f61706d2d706870)](https://camo.githubusercontent.com/ff6571c1ba0fdee1619a9869e10924726e71e98562d0c50d9d0a6b86e1814e96/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f736f6c617277696e64732f61706d2d706870)

---

SolarWinds APM PHP is an OpenTelemetry-based library for distributed tracing and observability in PHP applications. It provides automatic and manual instrumentation, seamless integration with the SolarWinds Observability platform, and supports modern PHP frameworks.

Prerequisites
-------------

[](#prerequisites)

Before you begin, ensure you have:

- [PHP 8.1+](https://www.php.net/)
- [PECL](https://pecl.php.net/)
- [Composer](https://getcomposer.org/)
- [pie](https://github.com/php/pie)

Check your versions:

```
php -v
composer -v
```

Installation
------------

[](#installation)

Install the SolarWinds APM library:

```
composer require solarwinds/apm:^9.0@alpha
```

Install a PSR-compatible HTTP client (required for OTLP exporter):

```
composer require guzzlehttp/guzzle
```

Set your service key (via environment variable):

```
export SW_APM_SERVICE_KEY=
```

Set the [APM collector endpoint](https://documentation.solarwinds.com/en/success_center/observability/content/system_requirements/endpoints.htm?#Find) which provides sampling settings, default is `apm.collector.na-01.cloud.solarwinds.com`. Also note down the OTLP ingestion endpoint that corresponds to your tenant, e.g. `otel.collector.na-01.cloud.solarwinds.com:443`. By default telemetry exports to a [local OTLP endpoint](https://opentelemetry.io/docs/languages/sdk-configuration/otlp-exporter/#otel_exporter_otlp_endpoint), see the example section below on exporting directly or through a local OpenTelemetry Collector to SolarWinds Observability.

```
export SW_APM_COLLECTOR=
```

Install [solarwinds/apm\_ext](https://packagist.org/packages/solarwinds/apm_ext) which caches sampling settings to reduce request latency:

Linux

```
pie install solarwinds/apm_ext
```

Windows

```
php pie.phar install solarwinds/apm_ext
```

To [minimize export delays](https://opentelemetry.io/docs/languages/php/exporters/#minimizing-export-delays), opentelemetry-php recommends an [agent](https://opentelemetry.io/docs/collector/deploy/agent/) collector to receive the telemetry. We recommend using the [SolarWinds OpenTelemetry Collector](https://github.com/solarwinds/solarwinds-otel-collector-releases) for better integration with SolarWinds Observability. Please refer to [Solarwinds OpenTelemetry Collector documentation](https://documentation.solarwinds.com/en/success_center/observability/content/intro/otel/otel-collector.htm) for install instructions, and the example section below on configuring it to receive telemetry from the PHP application and export to SolarWinds Observability.

Example Application
-------------------

[](#example-application)

This section demonstrates automatic instrumentation using Slim and SolarWinds APM.

### 1. Create a minimal Slim app

[](#1-create-a-minimal-slim-app)

```
composer init --no-interaction --require slim/slim:"^4" --require slim/psr7:"^1"
composer update
```

Create `index.php`:

```
