fanar-app/fanar

PHP and Laravel client for the Fanar debug receiver

Maintainers

Package info

github.com/fanar-app/fanar-php

pkg:composer/fanar-app/fanar

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v0.1.0 2026-05-24 08:30 UTC

This package is not auto-updated.

Last update: 2026-05-25 07:01:25 UTC


README

PHP and Laravel client for the Fanar debug receiver.

Installation

composer require fanar-app/fanar

Laravel setup

The service provider is auto-discovered. Publish the config to customise it:

php artisan vendor:publish --tag=fanar-config
FANAR_ENABLED=true
FANAR_HOST=127.0.0.1
FANAR_PORT=23517

Plain PHP setup

use Fanar\Fanar;

Fanar::configure([
    'host'    => '127.0.0.1',
    'port'    => 23517,
    'enabled' => true,
]);

Usage

Log a scalar

Fanar::log('hello');
Fanar::log(42);
Fanar::log(true);

Dump an array or object

Fanar::dump($user);
Fanar::dump(['key' => 'value']);

Capture an exception

Fanar::exception($e);

The origin is taken from the exception's own throw site, not the call site.

Time a block of code

$timer = Fanar::time('my-operation');

// ... work ...

$timer->stop();

Calling stop() more than once is safe — only the first call sends.

Labels and projects

Every method accepts an optional $options array:

Fanar::log('hello', ['label' => 'boot']);
Fanar::dump($user, ['label' => 'after-save', 'project' => 'auth']);
Fanar::exception($e, ['label' => 'payment']);

Global helper

The fanar() helper dispatches automatically based on type:

fanar('hello');   // → Fanar::log()
fanar($user);     // → Fanar::dump()
fanar($e);        // → Fanar::exception()

It also accepts options as a second argument:

fanar($user, ['label' => 'current-user']);

Laravel integration

Request tracking

The middleware is automatically registered on the web and api groups. Each request sends its method, path, status code, duration, and query count.

Query logging

All queries are captured automatically via the QueryExecuted event — no setup needed.

Model observer

Add the HasFanarLogging trait to any Eloquent model to log created, updated, and deleted events, including the changed attributes on updates:

use Fanar\Laravel\HasFanarLogging;

class User extends Model
{
    use HasFanarLogging;
}

Disabling

Set FANAR_ENABLED=false in .env to silence all sends without touching your code.

Requirements

  • PHP 8.1+
  • Laravel 10+ (optional)

License

MIT