كل حِزم SDK

PHP / Laravel

v1.4.0

allstak/sdk-php

AllStak/allstak-php-sdk

AllStak SDK for PHP, Laravel, and Guzzle. Captures errors, logs, inbound and outbound HTTP requests, PDO telemetry, and cron heartbeats.

Install

composer require allstak/sdk-php

Setup

<?php

require __DIR__ . '/vendor/autoload.php';

use AllStak\AllStak;
use AllStak\Facade;

AllStak::init([
    'apiKey' => getenv('ALLSTAK_API_KEY'),
    'environment' => getenv('APP_ENV') ?: 'production',
    'release' => getenv('ALLSTAK_RELEASE'),
    'service' => 'checkout-api',
]);

Facade::captureError(new RuntimeException('checkout failed'));
Facade::captureLog('info', 'payment retry', ['orderId' => 'ord_123']);

Laravel

The package auto-discovers its service provider. After composer require and setting one API key, the app is fully instrumented with no code changes.

Register the service provider manually only if your Laravel version does not auto-discover packages:

AllStak\Laravel\AllStakServiceProvider::class,

Add environment variables:

ALLSTAK_API_KEY=ask_live_xxx
ALLSTAK_ENVIRONMENT=production
[email protected]

What is captured automatically

Every collector is ON by default, guarded so missing framework pieces degrade gracefully, and individually toggleable via config/allstak.php or an env var:

CollectorEnv toggleCaptures
ExceptionsALLSTAK_CAPTURE_EXCEPTIONSUnhandled exceptions via the framework exception handler
Inbound HTTPALLSTAK_CAPTURE_REQUESTSRequest span + http-request record + request context + authed user
LogsALLSTAK_CAPTURE_LOGSLog lines; logged throwables at error+ promote to a captured error
DB queriesALLSTAK_CAPTURE_DBNormalized query, type, duration, connection
Outbound HTTPALLSTAK_CAPTURE_HTTP_CLIENTHttp:: client requests + spans + trace propagation
Queue jobsALLSTAK_CAPTURE_QUEUEPer-job span + breadcrumbs; failures captured as errors
Console / ArtisanALLSTAK_CAPTURE_CONSOLECommand span + breadcrumb + exit code
Scheduled tasksALLSTAK_CAPTURE_SCHEDULED_TASKSLifecycle breadcrumbs + cron heartbeats
CacheALLSTAK_CAPTURE_CACHEHit / miss / write / forget breadcrumbs
RedisALLSTAK_CAPTURE_REDISCommand breadcrumbs (requires Redis events enabled)
ViewsALLSTAK_CAPTURE_VIEWSView composing breadcrumbs
LivewireALLSTAK_CAPTURE_LIVEWIREComponent lifecycle breadcrumbs

Publish the config to tune any of these:

php artisan vendor:publish --tag=allstak-config

Running under Laravel Octane? The SDK resets its per-request trace/scope/buffers between pooled requests automatically (ALLSTAK_OCTANE_RESET).

Guzzle

Use the provided middleware to capture outbound HTTP requests when available in your app setup.

Configuration

OptionDescription
apiKeyProject API key.
environmentDeployment environment.
releaseApp version or commit SHA.
serviceLogical service name.
flushIntervalMsBackground flush interval.
bufferSizeMax buffered events.

Notes

AllStak::init([...]) initializes the singleton. For captures, use AllStak\Facade or the instance returned by AllStak::init(...).

Privacy

The SDK redacts common sensitive headers and fields. Avoid putting secrets in custom metadata.

Troubleshooting

  • No events: confirm ALLSTAK_API_KEY is set in the PHP runtime.
  • Laravel events missing: clear config cache after changing environment variables.
  • Short-lived command: flush before process exit when possible.

Contributing and Support

License

MIT