Docs menu

Integrations

Connect a Laravel app

Install the lampwick/laravel package, add your project's ingest token to .env and run php artisan lampwick:agent next to your app.

Updated View as Markdown

On this page

The lampwick/laravel package sends requests, queries, jobs, exceptions, logs and more from your Laravel app to Lampwick. Your app hands its records to an agent on the same server at 127.0.0.1:2407, so requests never wait on the network. The agent sends them in batches to https://app.lampwick.dev/ingest. While Lampwick is unreachable, it keeps up to 64 MB of records in memory and retries.

Requirements

  • PHP 8.2 or later with the curl extension.
  • Laravel 12 or 13.
  • Optional: the pcntl extension, so the agent sends its buffer when it stops.
  • The project's ingest token, from its Settings page. Only team owners see it.

Install the package

  1. Add the package:

    composer require lampwick/laravel
    
  2. Add the ingest token to .env:

    LAMPWICK_TOKEN=YOUR_PROJECT_TOKEN
    

    YOUR_PROJECT_TOKEN is the ingest token from the Connect your app card on the project's Settings page.

  3. Optional: to send your application logs, add the lampwick channel to your log stack:

    LOG_STACK=single,lampwick
    
  4. Start the agent:

    php artisan lampwick:agent
    

Check that it works

In a second terminal, run:

php artisan lampwick:test

It sends a test log record straight to Lampwick, to check your token and network, and checks that the agent runs. Then open your app: the request shows up in Lampwick within seconds.

Keep the agent running in production

Run one agent per server under a process manager, like a queue worker. Restart it after each deploy: it reads .env and the config only when it starts.

Laravel Forge

Go to your server → Daemons → New daemon:

FieldValue
Commandphp artisan lampwick:agent
Directoryyour site's directory, for example /home/forge/example.com/current
Userforge
Stop wait seconds15

Supervisor

[program:lampwick-agent]
command=php /var/www/example.com/artisan lampwick:agent
directory=/var/www/example.com
user=www-data
autostart=true
autorestart=true
stopsignal=TERM
stopwaitsecs=15
redirect_stderr=true
stdout_logfile=/var/log/lampwick-agent.log

Replace /var/www/example.com and www-data with your app's directory and PHP user, then load the program:

sudo supervisorctl reread && sudo supervisorctl update

On SIGTERM the agent stops taking records, sends what it has buffered and exits within LAMPWICK_AGENT_SHUTDOWN_TIMEOUT seconds (10 by default). Keep stopwaitsecs above that.

Docker and multiple servers

Every server or container that runs PHP needs an agent it can reach. Run it in the same container, or as a sidecar with LAMPWICK_AGENT_LISTEN set to 0.0.0.0:2407 for the agent and agent:2407 for the app. Never expose the agent's port to the internet: it accepts data from anyone who can reach it.

Configuration

Set everything with environment variables, or publish the config file with php artisan vendor:publish --tag=lampwick-config.

VariableDefaultWhat it does
LAMPWICK_TOKENnoneThe project's ingest token. Without it nothing is captured.
LAMPWICK_ENABLEDtruefalse turns the instrumentation off.
LAMPWICK_AGENT_LISTEN127.0.0.1:2407Address the agent listens on and the app sends to.
LAMPWICK_AGENT_SHUTDOWN_TIMEOUT10Seconds the agent takes to send its buffer when it stops.
LAMPWICK_SERVERhostnameServer name shown in Lampwick.
LAMPWICK_DEPLOYForge, Vapor or Cloud commitDeployment identifier.
LAMPWICK_REQUEST_SAMPLE_RATE1.0Share of requests to capture, from 0.0 to 1.0.
LAMPWICK_SCHEDULED_TASK_SAMPLE_RATE1.0Same, for scheduled tasks. Keep it at 1: alerts about missed runs need every run.
LAMPWICK_IGNORE_QUERIESfalseDon't capture database queries.
LAMPWICK_IGNORE_CACHE_EVENTSfalseDon't capture cache hits, misses and writes.
LAMPWICK_LOG_LEVELLOG_LEVELLowest log level sent through the lampwick channel.
LAMPWICK_CAPTURE_REQUEST_PAYLOADfalseInclude request bodies, with the fields below redacted.
LAMPWICK_REDACT_PAYLOAD_FIELDS_token,password,password_confirmationComma-separated.
LAMPWICK_REDACT_HEADERSAuthorization,Cookie,Proxy-Authorization,X-XSRF-TOKENComma-separated.

The package's README lists every variable.

Troubleshooting

What you seeCause and fix
Nothing shows up in LampwickRun php artisan lampwick:test. Check that the agent runs with the same .env as the app, and that LAMPWICK_TOKEN is set for both.
address already in useAnother agent already listens on that port. Stop it, or pick another LAMPWICK_AGENT_LISTEN (the app and the agent read the same setting).
HTTP 401 in the agent's logThe token is wrong or the project was deleted. Copy it again from the project's Settings page.
A changed .env has no effectThe config is cached. Run php artisan config:cache again and restart the agent.
Two apps on one server mix upThey can't: the agent refuses payloads with another token. Give each app its own LAMPWICK_AGENT_LISTEN port.