PHPackages                             spatie/flare-daemon - 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. [Logging &amp; Monitoring](/categories/logging)
4. /
5. spatie/flare-daemon

ActiveLibrary[Logging &amp; Monitoring](/categories/logging)

spatie/flare-daemon
===================

Local HTTP daemon for asynchronous Flare delivery

0.2.1(1mo ago)019.7k↑11278.6%[1 PRs](https://github.com/spatie/flare-daemon/pulls)1MITPHPPHP ^8.2CI passing

Since Apr 8Pushed 1w agoCompare

[ Source](https://github.com/spatie/flare-daemon)[ Packagist](https://packagist.org/packages/spatie/flare-daemon)[ Docs](https://github.com/spatie/flare-daemon)[ GitHub Sponsors](https://github.com/spatie)[ RSS](/packages/spatie-flare-daemon/feed)WikiDiscussions main Synced 2w ago

READMEChangelog (4)Dependencies (16)Versions (6)Used By (1)

A daemon to report error reports, performances traces and logs to Flare
=======================================================================

[](#a-daemon-to-report-error-reports-performances-traces-and-logs-to-flare)

[![Latest Version on Packagist](https://camo.githubusercontent.com/70a2972a83f1596b43e3c5c02bfeaeb5b7fc2563daac3a7b225cb5a73cceaf63/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7370617469652f666c6172652d6461656d6f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spatie/flare-daemon)[![Tests](https://github.com/spatie/flare-daemon/actions/workflows/run-tests.yml/badge.svg)](https://github.com/spatie/flare-daemon/actions/workflows/run-tests.yml)[![Total Downloads](https://camo.githubusercontent.com/93ec34420f06e52672b6986eb6dc8ca3fc46d8922d16b98a4f17c8d065a5d043/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7370617469652f666c6172652d6461656d6f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spatie/flare-daemon)

A long-running PHP process that accepts error reports, traces, and logs from your application over a local HTTP connection and forwards them to [Flare](https://flareapp.io) asynchronously. This removes Flare delivery from the critical path of your requests.

Support us
----------

[](#support-us)

[![](https://camo.githubusercontent.com/a5c4abb36a55a131a3c05d8dd4320725db3af19fa51bf7e0afccbacb3f2c40f4/68747470733a2f2f6769746875622d6164732e73332e65752d63656e7472616c2d312e616d617a6f6e6177732e636f6d2f666c6172652d6461656d6f6e2e6a70673f743d31)](https://spatie.be/github-ad-click/flare-daemon)

We invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us).

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards).

How it works
------------

[](#how-it-works)

```
PHP app ──HTTP──▸ daemon (local) ──HTTP──▸ Flare ingress

```

Payloads are buffered per API key and entity type and flushed immediately after being accepted. If the daemon is unreachable, the Flare client falls back to direct delivery automatically.

Architecture
------------

[](#architecture)

The daemon is a single PHP process built on ReactPHP's event loop:

- **HTTP server** — listens for local requests on the configured address
- **Ingest** — validates incoming payloads, routes them to the right buffer
- **Buffers** — per API key, per entity type (errors/traces/logs), in-memory only
- **Flush cycle** — a periodic timer (every 1s) checks buffer age and size thresholds
- **Upstream** — sends buffered payloads to Flare ingress over HTTP
- **Quota state** — tracks 429/403 responses and pauses ingestion per key/type
- **Test payloads** — bypass the buffer entirely, make a synchronous upstream request, and return the upstream response to the caller
- **Composer.lock watcher** — optional periodic timer that triggers graceful shutdown on file changes
- **Signal handlers** — SIGINT/SIGTERM trigger graceful shutdown (drain buffers, then stop)

Packaging &amp; Versioning
--------------------------

[](#packaging--versioning)

### Default install, opt-in transport

[](#default-install-opt-in-transport)

The intended integration model is that the daemon is installed by default through Flare's shared PHP client packages, including Laravel integrations that depend on that client layer. The presence of the daemon package should not enable daemon transport automatically.

Runtime activation remains explicit. Installation and onboarding docs may steer new users toward enabling the daemon, especially for logging, but "installed by default" and "enabled by default" are separate decisions.

### Distribution channels

[](#distribution-channels)

Composer is the default application install path. The daemon exposes a stable vendor binary for local execution, process managers, and framework wrappers.

PHAR, Docker, and Helm are additional operator-facing distribution channels:

- **Composer / vendor bin** — the default path for app installs, backed by the bundled PHAR
- **PHAR** — a standalone artifact for operators who want a single-file deployment
- **Docker** — a container artifact for containerized environments
- **Helm** — a Kubernetes DaemonSet chart published as an OCI chart to GitHub Container Registry

Laravel may add convenience wrappers around the daemon binary, but the daemon itself is framework-agnostic and must work for standalone PHP and Laravel users alike.

### Versioning model

[](#versioning-model)

The daemon should have one canonical version stream owned by this repository's Git tags. Packagist package versions, PHAR releases, Docker image tags, and Helm chart versions should all track that same daemon version. The Docker image tags are `v`-prefixed, while the Helm chart version is plain SemVer and uses a `v`-prefixed `appVersion`.

Client packages should depend on compatible daemon versions, but should not own the daemon's version number themselves. The daemon release cadence and operator-facing artifacts are defined at the daemon package level.

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

[](#installation)

### Composer / vendor bin

[](#composer--vendor-bin)

Flare's PHP client packages install the daemon package by default so applications can run the daemon from Composer's vendor binary directory:

```
php vendor/bin/flare-daemon
```

The Composer package ships a bundled PHAR for this binary. Its internal ReactPHP runtime is isolated from the application's Composer dependency graph.

When working from this repository, use `php src/daemon.php` for source development. The Composer binary expects the bundled `build/daemon.phar` to be present.

### Docker

[](#docker)

```
docker run -d --name flare-daemon -p 8787:8787 ghcr.io/spatie/flare-daemon
```

### Helm

[](#helm)

The Helm chart runs Flare Daemon as a Kubernetes DaemonSet and exposes it through an in-cluster Service:

```
helm install flare-daemon \
    oci://ghcr.io/spatie/charts/flare-daemon \
    --version 1.2.3 \
    --namespace flare-daemon \
    --create-namespace
```

To install the chart directly from a local checkout of this repository:

```
helm install flare-daemon ./charts/flare-daemon \
    --namespace flare-daemon \
    --create-namespace
```

Applications can send daemon traffic to:

```
http://flare-daemon.flare-daemon.svc.cluster.local:8787

```

The chart runs one daemon pod per Kubernetes node and defaults to `service.internalTrafficPolicy=Local`, so application pods use the daemon endpoint on their own node. If a node-local daemon is unavailable, Flare clients should fall back to direct delivery.

### PHAR

[](#phar)

```
php build/daemon.phar
```

Usage
-----

[](#usage)

### Verbose mode

[](#verbose-mode)

By default the daemon logs lifecycle events (started, stopped) and a periodic summary of forwarded payloads. Pass `--verbose` (or `-v`) to also log every individual payload at `DEBUG` level:

```
php build/daemon.phar --verbose
```

```
docker run -d --name flare-daemon -p 8787:8787 ghcr.io/spatie/flare-daemon --verbose
```

### Configuration

[](#configuration)

All configuration is done through environment variables:

VariableDefaultDescription`FLARE_DAEMON_LISTEN``127.0.0.1:8787`Address to listen on`FLARE_DAEMON_UPSTREAM``https://ingress.flareapp.io`Flare ingress URL`FLARE_DAEMON_BUFFER_BYTES``262144` (256 KB)Size threshold per buffer (used by maintenance safety net)`FLARE_DAEMON_FLUSH_AFTER_SECONDS``10`Seconds before maintenance flushes oldest buffered items (safety net)`FLARE_DAEMON_UPSTREAM_TIMEOUT_SECONDS``10`Timeout in seconds for upstream requests`FLARE_COMPOSER_LOCK`*(none)*Path to `composer.lock` — daemon stops when the file changes### Smoke-testing with a real API key

[](#smoke-testing-with-a-real-api-key)

Start the daemon, then use `tests/test.sh` to send a real error payload through the full buffering/flushing path:

```
php src/daemon.php --verbose &
bash tests/test.sh YOUR_API_KEY
```

The script checks `/health`, sends a normal error to `/v1/errors`, and polls `/status` until the buffer drains. Pass `-u URL` to target a different daemon address.

### Building

[](#building)

```
bash build.sh
```

This downloads [Box](https://github.com/box-project/box) (if needed) and compiles `build/daemon.phar`, which is used by the Composer vendor binary, Docker image, and GitHub release asset.

The PHAR is built from `runtime/composer.json`, a small build-only Composer project that contains the daemon's ReactPHP runtime dependencies. The root `composer.json` stays dependency-light so installing `spatie/flare-daemon` in an application does not constrain the application's PSR-7 or ReactPHP dependency graph.

Maintainers can use [`RELEASING.md`](RELEASING.md) for the GitHub-release-driven artifact publishing process.

### Load testing

[](#load-testing)

Start the daemon in test mode (accepts payloads, doesn't forward upstream), then run the k6 script:

```
php src/daemon.php --test &
k6 run loadtest/loadtest.js
```

On an M-series Mac the daemon sustains ~18,000 reports/sec with p95 latency under 11ms. See `loadtest/README.md` for details.

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](https://github.com/spatie/.github/blob/main/CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Alex Vanderbist](https://github.com/alexvanderbist)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

47

—

FairBetter than 93% of packages

Maintenance95

Actively maintained with recent releases

Popularity29

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity40

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 74% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~11 days

Total

4

Last Release

46d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/7535935?v=4)[Spatie](/maintainers/spatie)[@spatie](https://github.com/spatie)

---

Top Contributors

[![AlexVanderbist](https://avatars.githubusercontent.com/u/6287961?v=4)](https://github.com/AlexVanderbist "AlexVanderbist (37 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (8 commits)")[![freekmurze](https://avatars.githubusercontent.com/u/483853?v=4)](https://github.com/freekmurze "freekmurze (4 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (1 commits)")

---

Tags

errorsflarelogsmonitoringperformancephpspatieflareerror-trackingperformance-monitoringflare-daemon

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/spatie-flare-daemon/health.svg)

```
[![Health](https://phpackages.com/badges/spatie-flare-daemon/health.svg)](https://phpackages.com/packages/spatie-flare-daemon)
```

###  Alternatives

[spatie/laravel-activitylog

A very simple activity logger to monitor the users of your website or application

5.8k50.2M436](/packages/spatie-laravel-activitylog)[spatie/flare-client-php

Send PHP errors to Flare

177156.9M21](/packages/spatie-flare-client-php)[facade/flare-client-php

Send PHP errors to Flare

518100.9M4](/packages/facade-flare-client-php)[spatie/laravel-health

Monitor the health of a Laravel application

87411.3M153](/packages/spatie-laravel-health)[spatie/laravel-ray

Easily debug Laravel apps

31740.3M3.4k](/packages/spatie-laravel-ray)[spatie/laravel-http-logger

A Laravel package to log HTTP requests

6744.7M12](/packages/spatie-laravel-http-logger)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
