Skip to content
v1
Docs

PHP SDK

PHP SDK

The PHP SDK calls the WatchTower15 API, counts what your application does as custom metrics and ships its logs to log ingest, from one Client. It builds, retries and batches the calls for you, and turns every failure into a typed exception.

  • The REST API. Every /v1 operation is a method on a service: $wt15->servers->list(), $wt15->incidents->acknowledge($uuid). See the REST API.
  • Custom metrics. Push points, or count in the request path with the aggregator and let a flush send them once a minute. See custom metrics.
  • Logs. A Monolog handler and a PSR-3 logger that send lines to log ingest. See logs.
You use Install Page
Laravel 12 or 13 composer require watchtower15/laravel Laravel
Symfony 6.4, 7.4 or 8 composer require watchtower15/symfony Symfony
CakePHP 5.1 or later composer require watchtower15/cakephp CakePHP
Anything else composer require watchtower15/sdk Plain PHP and other frameworks

A bridge requires the core, watchtower15/sdk, so you install one package. All four are released together, at one version.

PHP 8.3 and later, until each minor’s own security support ends. Laravel 12 and 13; Symfony 6.4, 7.4 and 8.x (8.x on PHP 8.4 and later); CakePHP 5.1 and later. The SDK follows Semantic Versioning, independently of the API’s v1: a new API operation is additive and ships in the next release, and a change to the SDK’s own signatures is a major one. The full policy and the tested versions are in the package README.

Each credential is created in the console and is good for one job. The SDK checks its shape before it sends anything, and names a credential given in the wrong place.

Credential Variable Used for Created
API key wt15ak_… WT15_API_KEY me() and the REST API. Personal: keep it out of shared code. Authentication and keys
Metric source token wt15ms_… WT15_METRICS_TOKEN Pushing and listing custom metrics Metric sources
Log source token wt15ls_… WT15_LOGS_TOKEN Pushing log lines Custom log sources

Credentials are never logged, never put in an exception message and never serialised; a dump of a Client shows each as its prefix and last four characters.

If the WatchTower15 agent runs on the host, let it tail your log files: no token in the application and no HTTP from PHP. Use the SDK’s log handler where the agent does not run.

Terminal window
export WT15_API_KEY=… WT15_METRICS_TOKEN=… WT15_LOGS_TOKEN=…
vendor/bin/watchtower15 test

The Laravel, Symfony and CakePHP bridges have their own test command, which reads the framework’s configuration.