# PHP [Languages](README.md) · [Shared configuration](../../common.md) · [Verification](../../verification.md) For a full application example, use the [WordPress, PHP, and Apache integration](../../../../integrations/wordpress-php-apache/README.md), to configure automatic request/database trace collection on an existing server and forward it to Corridora. Use PHP **8.2 or later** and Composer 2. This example pins OpenTelemetry PHP SDK **1.18.0**, OTLP exporter **1.6.0**, and the Guzzle HTTP adapter **1.1.0**. It creates one manual trace and sends it to the local [Collector](../../../collector.md). The CLI example was verified with PHP **8.4.14**. The PHP SDK lists traces, metrics, and logs as Stable, checked on **2026-12-02**; this example configures traces only. ## Install Create a separate example directory: ```sh mkdir corridora-php cd corridora-php composer init --name=example/corridora-php --no-interaction composer config allow-plugins.php-http/discovery false composer require \ open-telemetry/sdk:1.18.0 \ open-telemetry/exporter-otlp:1.6.0 \ php-http/guzzle7-adapter:1.1.0 ``` The adapter supplies the HTTP client used by the exporter. This manual example does not require the OpenTelemetry PHP extension. Keep `composer.json` and `composer.lock`; use `composer install` to reproduce the resolved dependencies. Start the local Collector, then configure OTLP/HTTP with Protobuf: ```sh export OTEL_PHP_AUTOLOAD_ENABLED=false export OTEL_EXPORTER_OTLP_ENDPOINT='http://127.0.0.1:4318' export OTEL_EXPORTER_OTLP_PROTOCOL='http/protobuf' unset OTEL_EXPORTER_OTLP_TRACES_ENDPOINT OTEL_EXPORTER_OTLP_TRACES_PROTOCOL unset OTEL_EXPORTER_OTLP_HEADERS OTEL_EXPORTER_OTLP_TRACES_HEADERS ``` The endpoint above is a base URL; the exporter adds `/v1/traces`. A signal-specific endpoint overrides it and must include that path. Use a container-reachable Collector address when the application runs in Docker or Kubernetes. ## Initialize and emit Save as `app.php`: ```php setResource(ResourceInfo::create(Attributes::create([ 'service.name' => 'corridora-php', 'service.version' => 'example-1', 'deployment.environment.name' => 'development', ]))) ->addSpanProcessor(new SimpleSpanProcessor( (new SpanExporterFactory())->create() )) ->build(); try { $tracer = $provider->getTracer('corridora.examples.php'); $span = $tracer->spanBuilder('example.calculate')->startSpan(); $scope = $span->activate(); try { $span->setAttribute('example.language', 'php'); usleep(50_000); printf("trace_id=%s\n", $span->getContext()->getTraceId()); } finally { $scope->detach(); $span->end(); } } finally { $provider->shutdown(); } ``` Run the example and retain the printed trace ID: ```sh php app.php ``` The simple processor exports synchronously when the span ends. For a production service, use an appropriate batch processor and manage flushing around the actual PHP worker or request lifecycle. Long-running workers should retain their provider until shutdown. Do not reuse a provider after shutting it down. ## Instrument an application For Laravel, Symfony, Slim, or another supported framework, choose matching instrumentation from the [PHP instrumentation registry](https://opentelemetry.io/ecosystem/registry/?language=php&component=instrumentation). Zero-code instrumentation requires the OpenTelemetry PHP extension plus the relevant Composer instrumentation packages. Follow the [upstream zero-code setup](https://opentelemetry.io/docs/zero-code/php/). Choose one SDK initialization path. Do not combine this explicit provider with a separate autoloaded provider. The example uses its provider directly; libraries that obtain tracers through the global API require the application's provider to be registered globally. Activate a span while its child work runs. HTTP boundaries also need W3C context extraction and injection: creating a manual span alone does not propagate browser or upstream trace context. Preserve the `traceparent` header through proxies and use supported HTTP instrumentation or the propagation API. Metrics and logs require their own providers, exporters, and instrumentation or logging bridge. PHP `echo`, `error_log()`, and ordinary application logs are not automatically exported by this trace provider. ## Direct export and verification For direct export, securely load the ingest credential as described in [shared configuration](../../common.md), then use your HTTPS ingest base URL: ```sh export OTEL_EXPORTER_OTLP_ENDPOINT="$CORRIDORA_OTLP_ENDPOINT" export OTEL_EXPORTER_OTLP_HEADERS="X-CORRIDORA-KEY=${CORRIDORA_INGEST_KEY}" php app.php ``` Remove stale trace-specific endpoint or header overrides before switching destinations. Keep credentials out of source files, browser code, and captured output. Search Corridora for service `corridora-php` and the printed trace ID. Expect `example.calculate` to last about 50 milliseconds. A printed ID proves span creation; use [verification](../../verification.md) to confirm Collector delivery and query visibility. Check exporter warnings, the PHP process's environment, the selected Composer autoloader, and shutdown behavior if the span is absent. Source basis: [OpenTelemetry PHP status and requirements](https://opentelemetry.io/docs/languages/php/), [instrumentation](https://opentelemetry.io/docs/languages/php/instrumentation/), [SDK configuration](https://opentelemetry.io/docs/languages/php/sdk/), [OTLP exporters](https://opentelemetry.io/docs/languages/php/exporters/), and the pinned [SDK](https://packagist.org/packages/open-telemetry/sdk) and [exporter](https://packagist.org/packages/open-telemetry/exporter-otlp) package manifests.