Skip to content

ZurabWeb/reliably-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

reliably/reliably

Reliably turns your outbound API usage—Stripe, OpenAI, webhooks—into live, crowd-derived latency and outcome signals everyone benefits from sharing. Reliably::wrap() proxies typed clients with provider detection; monitorGuzzle() (opt-in) adds Guzzle middleware so hostname + pathname reach ingest (never bodies or secrets).

Privacy: hashed project identifiers by default; Guzzle taps never capture bodies or Authorization for Reliably payloads. See PRIVACY.md.

Runs where PHP runs: FPM / Apache register shutdown flushing; Laravel queues and long workers should call flush() on a timer or between jobs.

composer require reliably/reliably

Quick Start

use Reliably\Reliably;

$stripe = Reliably::wrap(new \Stripe\StripeClient(getenv('STRIPE_SECRET_KEY')));
$openai = Reliably::wrap(new \OpenAI\Client(getenv('OPENAI_API_KEY')));

$charge = $stripe->charges->create(['amount' => 2000, 'currency' => 'usd']);
// Use $openai the same way you would the underlying OpenAI client.

Aggregates surface at reliably.dev and reliably.sh.

With Project ID

use Reliably\Reliably;

$reliably = new Reliably(['projectId' => 'proj_xxx']);
$stripe = $reliably->wrapClient(new \Stripe\StripeClient(getenv('STRIPE_SECRET_KEY')));

What Gets Tracked

Mode What you send Notes
wrap() / wrapClient() Curated provider, method-chain endpoint, status, latency, error class, resolution: wrap Proxy via WrappedClient; no raw URLs.
monitorGuzzle() Hostname + pathname-only endpoint, method, status, latency; optional unknown hosts Ingest maps host → provider and resolution (registry / fallback).

Never sent: bodies, secret-bearing headers, or URLs with query strings.

Supported Providers (wrap)

Fingerprints include (among others):

  • Stripe · OpenAI · Anthropic · Twilio · SendGrid · Resend · Supabase · Firebase · AWS · GitHub · Shopify · Slack

Unrecognized clients fall back to namespace / short class name heuristics.

Outbound Monitoring (monitorGuzzle())

PHP path is Guzzle HandlerStack middleware (not global monkey-patching):

use GuzzleHttp\Client;
use GuzzleHttp\HandlerStack;
use Reliably\Reliably;

$reliably = new Reliably(['projectId' => 'proj_xxx']);
$stack = HandlerStack::create();
$reliably->monitorGuzzle($stack, reportUnknown: false);

$client = new Client(['handler' => $stack]);
// outbound requests through $client emit pathname + host slices to ingest

Requires guzzlehttp/guzzle ^7.8 (declared in this package). wrap() does not require Guzzle in your app code.

Configuration

$reliably = new Reliably([
    'projectId'    => 'proj_xxx',    // optional
    'endpoint'     => 'https://...', // custom ingest (self-hosted)
    'maxBatchSize' => 100,           // max events before flush
    'enabled'      => true,          // disable in tests
    'debug'        => false,         // log to error_log
]);

How Flushing Works

  • Web SAPI (FPM / mod_php): register_shutdown_function() flushes at end of request.
  • Long-running workers: call $reliably->flush() manually or on a timer (queues, ReactPHP, Swoole, etc.).

Design Principles

  • Never crash — telemetry paths swallow failures where safe
  • Fire and forget — ingest outages should not break user requests
  • Transparent wrap() — same method chains as the underlying SDK

Other Language SDKs

Requirements

  • PHP 8.1+
  • guzzlehttp/guzzle ^7.8 for monitorGuzzle() only

License

MIT

About

PHP SDK for Reliably — third-party API reliability intelligence

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages