---
title: "Send OpenTelemetry from Laravel to your Mac"
description: "Install the OpenTelemetry PHP extension and the Laravel auto-instrumentation, set four environment variables, and read your Laravel traces in one window."
source: "https://getloggerhead.com/docs/send-telemetry/laravel/"
---

# Send OpenTelemetry from Laravel to your Mac

> Install the OpenTelemetry PHP extension and the Laravel auto-instrumentation, set four environment variables, and read your Laravel traces in one window.

PHP instruments Laravel with an extension and a Composer package. No code changes.

## Before you start

- Loggerhead is open.
- You know the effective port. Open **Collectors → Loggerhead receiver → Connection** and copy the HTTP port. The first workspace uses 4318. See [Ports and the effective port](/docs/getting-started/ports-and-the-effective-port/).

## Step 1: install the extension

Auto-instrumentation needs the `opentelemetry` PHP extension.

```bash
pecl install opentelemetry
```

Add `extension=opentelemetry.so` to your `php.ini`, then check it with `php -m | grep opentelemetry`.

## Step 2: install the packages

```bash
composer require \
  open-telemetry/sdk \
  open-telemetry/exporter-otlp \
  open-telemetry/opentelemetry-auto-laravel
```

## Step 3: set the endpoint

```bash title=".env"
OTEL_PHP_AUTOLOAD_ENABLED=true
OTEL_SERVICE_NAME=my-laravel-app
OTEL_EXPORTER_OTLP_ENDPOINT=http://127.0.0.1:4318
OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf
```

`OTEL_PHP_AUTOLOAD_ENABLED` is the switch. Without it the packages load and do nothing.

Start the app with `php artisan serve` and open one route.

## What arrives

| Signal | State |
| --- | --- |
| Traces | Every request, with the route, the queries, and the queued jobs. |
| Metrics | Only what you record yourself. |
| Logs | Add `OTEL_LOGS_EXPORTER=otlp` and the Monolog handler of the Laravel package. |

## Tag the environment

```bash
OTEL_RESOURCE_ATTRIBUTES=deployment.environment.name=staging
```

See [Workspaces and environments](/docs/getting-started/workspaces-and-environments/).

## Then read it with your agent

1. Open **Traces** in Loggerhead and click a request to open its waterfall.
2. Connect your coding agent once, and it reads the same data. See [Claude Code](/docs/connect-your-ai-tool/claude-code/).
