Documentation/PHP / Nette

PHP / Nette

Instrument Nette applications.

Use a native DI extension, automatic application lifecycle tracking and fail-safe buffered delivery.

Nette 3.2–3.3Package v0.2.0Production ready
01

Quickstart

Install the native extension.

Install the package and register its compiler extension in your NEON configuration. Composer installs the shared PHP Core automatically.

Terminalbash
composer require apirelio/nette:^0.2
app/config/common.neonyaml
# app/config/common.neon
extensions:
    apirelio: Apirelio\Nette\DI\ApirelioExtension

apirelio:
    apiKey: %env.APIRELIO_API_KEY%
    endpoint: https://api.apirelio.com
    service: billing-api
    environment: production
    release: 2026.07.30.1
    paths:
        - /api/*
    metadataKeys:
        - region
02

Automatic tracking

No presenter instrumentation.

The extension hooks into onRequest, onResponse and onError. It captures matching application requests, normalizes numeric, UUID and ULID path segments, and clears request context after delivery.

R

onRequest

Starts timing and associates the Nette application request.

onResponse

Emits the normalized successful or handled response event.

!

onError

Records an unhandled exception without replacing or masking it.

03

Customer context

Connect your authentication model.

Implement the customer and application resolver contracts, register them as services and reference the service names from the Apirelio section.

CurrentCustomerResolver.phpphp
use Nette\Application\Request;
use Apirelio\Nette\Contracts\CustomerResolver;
use Apirelio\Nette\Data\ApirelioCustomer;

final class CurrentCustomerResolver implements CustomerResolver
{
    public function resolve(Request $request): ?ApirelioCustomer
    {
        return new ApirelioCustomer(
            'customer_42',
            'Acme Europe',
            'growth',
        );
    }
}
services.neonyaml
services:
    app.customerResolver: App\Analytics\CurrentCustomerResolver
    app.applicationResolver: App\Analytics\CurrentApplicationResolver

apirelio:
    customerResolver: app.customerResolver
    applicationResolver: app.applicationResolver
04

Diagnostics

Enrich the current request.

Inject ApirelioManager into a presenter or service. Only metadata keys declared in metadataKeys are retained.

InvoiceService.phpphp
final class InvoiceService
{
    public function __construct(
        private ApirelioManager $apirelio,
    ) {}

    public function create(): void
    {
        $this->apirelio->addMetadata(['region' => 'eu-central']);
        $this->apirelio->setErrorCode('VALIDATION_FAILED');
    }
}
05

Manual events

Track an integration milestone.

Use a low-cardinality business event when a meaningful integration action is not represented by one HTTP endpoint.

Nette servicephp
$apirelio->track(
    event: 'invoice.created',
    integration: 'fakturoid',
    metadata: ['region' => 'eu-central'],
);
06

Reliability

Buffer by default.

The default fileBuffer transport persists events in a locked NDJSON file and flushes them by size or interval. Use a writable application temp directory.

common.neonyaml
apirelio:
    transport: fileBuffer
    bufferPath: %tempDir%/apirelio/events.ndjson
    batchSize: 500
    flushIntervalSeconds: 10
Local diagnostics

Switch to transport: sync when verifying credentials and ingestion during development.