Download the PHP package getfaultline/faultline-php without Composer

On this page you can find all versions of the php package getfaultline/faultline-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package faultline-php

getfaultline/faultline-php

The PHP SDK for Faultline, a self-hostable error-tracking platform. It captures exceptions, PHP errors and messages, adds context (stack traces with source, breadcrumbs, request data, user, tags), scrubs secrets, and sends batched, gzip-compressed events to the Faultline ingest API.

Quickstart

That is all a plain PHP app needs: no middleware. init() installs an exception handler, an error handler and a fatal-error shutdown handler, so uncaught exceptions, warnings and fatal errors are reported automatically. Everything is sent at the end of the request.

Every function is also available as a static method: \Faultline\Faultline::init([...]), Faultline::captureException($e), and so on.

A runnable script is in examples/plain.php:

CLI scripts and workers

There is nothing extra to do for a script: the queue is flushed when it exits. Call \Faultline\flush() to send immediately, for example before a long sleep(). In CLI processes the queue is also sent automatically once it holds 20 events, so long-running workers never hold events for long. The Laravel integration flushes between queue jobs.

Laravel

The service provider is auto-discovered. Add your key to .env:

Optionally publish the config file to config/faultline.php:

What you get:

Without FAULTLINE_API_KEY the SDK stays disabled, which is handy for local development. Capture manually anywhere with \Faultline\captureException($e). The config keys are snake_case versions of the options below (api_key, sample_rate, ignore_errors, before_send, ...), plus breadcrumbs.logs and breadcrumbs.queries. before_send takes a container-resolved callable: an invokable class name, "Class@method" or [Class::class, 'method'], so php artisan config:cache keeps working.

Slim, Mezzio and other PSR-15 apps

The middleware forks a scope per request, attaches request data and a navigation breadcrumb, captures any Throwable that escapes the inner handler, and re-throws it unchanged. It needs psr/http-server-middleware.

PSR-3: wrap any logger with new Faultline\Integrations\Psr3\BreadcrumbLogger($logger) to turn log calls into log breadcrumbs (needs psr/log 2 or 3).

API

Function Description
init(array $options) Configure the SDK. Calling it again replaces the previous client.
captureException(Throwable $e, ['tags', 'extra', 'user', 'level', 'fingerprint', 'contexts']) Capture an exception. Returns the eventId, or null when the event was dropped or the SDK is disabled.
captureMessage(string $message, string $level = 'info') Capture a message. The second argument may also be a capture context array.
setUser(['id', 'email', 'username', 'ipAddress']) / setUser(null) Set or clear the user on the current scope.
setTag($key, $value) / setTags([...]) Searchable string tags.
setContext($name, [...]) / setExtra($key, $value) Structured context or arbitrary extra data.
addBreadcrumb(['type', 'category', 'message', 'level', 'data']) Manual breadcrumb. type is one of default, http, log, query, navigation.
withScope(fn (Scope $scope) => ...) Run code with a forked scope. Changes apply only inside the callback. Returns the callback's result.
flush(int $timeoutMs = 2000) Send queued events now. Returns false on timeout and never throws.
close(int $timeoutMs = 2000) Flush, remove the handlers, and disable the SDK.
Faultline::isEnabled() / Faultline::lastEventId() true once init has succeeded / id of the last queued event.

setUser, setTag, setContext, setExtra and addBreadcrumb write to the current scope. Outside withScope (or the PSR-15 middleware) that is the global scope, which in PHP lives for exactly one request.

Options

Option Type Default Description
apiKey string required Public ingest key (flt_ingest_...). Sent as X-Faultline-Key.
endpoint string https://api.faultsline.dev Base URL of the Faultline server. Override it when self-hosting.
environment string - e.g. production, staging.
release string - e.g. [email protected] or a git sha.
serverName string gethostname() Reported as serverName.
sampleRate float 0..1 1.0 Fraction of events to send.
maxBreadcrumbs int 50 Breadcrumbs kept per scope (capped at 100).
sendDefaultPii bool false When false, the user IP and the cookie, set-cookie, authorization, proxy-authorization, x-forwarded-for, x-real-ip and forwarded headers are removed, and SQL bindings are not recorded.
beforeSend callable(array $event): ?array - Modify or drop (null) an event. Runs after scrubbing. If it throws, the event is dropped.
ignoreErrors list<string> [] Class names (subclasses match too, via instanceof) or regex strings such as '/timeout/i', tested against the exception type, the message and "Type: message".
integrations array ['exceptionHandler' => true, 'errorHandler' => true, 'fatalErrorHandler' => true] Toggle the PHP handlers (see below).
enabled bool true false turns the SDK into a no-op (apiKey is then not required).
debug bool false Log SDK internals (dropped events, retries, invalid options) with error_log().

Invalid options never throw:

PHP handlers

Self-hosting

Set endpoint to your server's base URL. The SDK posts to {endpoint}/api/v1/ingest/events:

In Laravel, set FAULTLINE_ENDPOINT.

What gets sent

Each event follows the shared Faultline event contract: eventId (uuid v4), timestamp, level, platform: "php", exception (type = class name, value, frames ordered oldest → newest, the getPrevious() chain as cause), message, tags, user, request, contexts (runtime, os, plus your own), breadcrumbs, extra, fingerprint, environment, release, serverName, and sdk: { name: "getfaultline/faultline-php", version }.

Frames come from Throwable::getTrace() plus the throw location, with function names like App\Http\Controllers\OrderController->show or App\Support\Str::slug. Frames outside /vendor/ are marked inApp and get ±5 lines of source context.

The SDK enforces the pinned limits before sending:

Field Limit
Frames 100 (newest kept)
Breadcrumbs 100
Tags 50 (key ≤ 32 chars, value ≤ 200 chars)
message / exception.value 8192 chars
Source context ±5 lines, each ≤ 300 chars
exception.cause chain 5 exceptions in total
Batch ≤ 50 events and ≤ 1 MB

Scrubbing (client side, same rules as the server and the Node SDK):

Delivery:

Architecture

The SDK follows Clean Architecture. Dependencies point inward only, and tests/Unit/ArchitectureTest.php enforces this in CI.

See ARCHITECTURE.md for the decision log.

Development

Command What it does
composer install Install dev dependencies.
composer cs PHP-CS-Fixer dry run (PSR-12 + strict types). composer cs:fix applies it.
composer analyse PHPStan: src, config and examples at level max, tests at level 8.
composer test PHPUnit: unit, integration (a php -S mock ingest server and real PHP subprocesses) and Laravel (Testbench).
composer check All of the above.

Every produced payload is validated against tests/Fixtures/event.schema.json, a test-only JSON Schema that mirrors the shared contract.

The SDK reads no environment variables of its own; everything is passed to init. The example script and the Laravel config read FAULTLINE_API_KEY and FAULTLINE_ENDPOINT.

Publishing

Packagist only publishes packages from a public Git repository. To release:

  1. Push this repository to a public host, e.g. github.com/getfaultline/faultline-php.
  2. Submit the repository URL at packagist.org/packages/submit (once), and enable the GitHub hook so new tags are picked up automatically.
  3. Tag a release: git tag v0.1.0 && git push --tags. Packagist versions come from tags; composer.json has no version field on purpose.

License

MIT


All versions of faultline-php with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
ext-curl Version *
ext-json Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package getfaultline/faultline-php contains the following files

Loading the files please wait ...