Download the PHP package nightshift-foundry/laravel-alertstream without Composer

On this page you can find all versions of the php package nightshift-foundry/laravel-alertstream. 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 laravel-alertstream

AlertStream - Laravel Alert & Exception Reporting

Tests Code Style codecov Dependabot

Latest Stable Version Total Downloads

A lightweight, extensible Laravel package that captures exceptions and sends rich alerts to Slack, Teams, Discord, and Mail, plus any custom destination you build. No configuration required for exception reporting, queue-friendly, and runs completely off your request hot path.

Features

Installation

Publish the config:

Built-in Channels

Activate any channel by adding its name to ALERTSTREAM_CHANNELS and supplying its credentials. No code changes needed.

Slack

Microsoft Teams

Teams no longer supports direct incoming webhooks the way Slack and Discord do. The reliable approach is a Power Automate flow that receives the alert payload and posts it as a formatted chat message.

1. Create the flow

  1. Go to make.powerautomate.com and create a new Instant cloud flow
  2. Choose "When an HTTP request is received" as the trigger
  3. Add a "Post message in a chat or channel" action — set Post as to Flow bot, choose your team and channel
  4. Set the Message field to the expression:

  5. Save the flow — the HTTP trigger URL will appear on the trigger step. Copy it.

2. Configure the package

That's it. AlertStream POSTs an HTML-formatted payload to your flow, which passes the message straight through to the channel. The message includes severity-coded colours, bold exception details, file location, environment, and a View Full Stacktrace link when snapshots are enabled.

Note: The HTTP trigger URL contains a SAS token and acts as a secret — treat it like a password and store it in your .env, never in source control.

Discord

Mail

Multiple channels at once:

Custom Channels

Need PagerDuty, Telegram, OpsGenie, or your own internal system? Implement the AlertChannel contract and tag it. AlertStream discovers it automatically alongside the built-in ones.

1. Implement the contract

2. Register and tag it in any service provider

AlertStream iterates every class tagged alertstream.channel, built-in or custom, and calls send() on each one. No config keys to add, no arrays to update.

Automatic Exception Reporting

Once installed, all application exceptions are captured automatically with no changes to app/Exceptions/Handler.php.

Every alert includes:

Field Description
Exception class & message What went wrong
File & line Where it happened
Severity critical / error / warning (auto-detected)
URL, method, IP, user agent Request context
User ID & email If authenticated
Environment & hostname Runtime context

Toggle reporting:

Muting Exceptions

Some exceptions are noise: 404s, validation errors, unauthenticated requests. AlertStream ships with sensible defaults already muted, and you can extend the list freely.

Default muted exceptions

These are ignored out of the box:

Exception Reason
AuthenticationException User not logged in, expected and not actionable
AuthorizationException Access denied, expected and not actionable
ValidationException Form/API validation failure, part of normal flow
HttpResponseException Manually thrown HTTP responses, intentional
NotFoundHttpException 404, common bot traffic and not worth alerting
MethodNotAllowedHttpException 405, misconfigured client and not actionable

Adding your own muted exceptions

Append to the mute array in config/alertstream.php:

Muting is class-hierarchy aware, so muting a parent class also suppresses all its subclasses.

Unmuting a default at runtime

If you need to re-enable reporting for a default muted class, call report() on the Handler in a service provider:

Queue Configuration

Why queue matters

When an exception is thrown, AlertStream needs to send HTTP requests to Slack, Teams, Discord, etc. These calls can take 100-500 ms each. With the queue enabled, this work is handed off to a background worker instantly and the request returns to the user without waiting. With the queue disabled, all channel calls happen inline, adding their latency directly to the response time.

Recommendation: keep the queue enabled in production (ALERTSTREAM_QUEUE=true, the default). Use false only in local dev or when you have no queue worker.

Queue on (default, recommended for production)

When the queue is on, you must have at least one queue worker running, otherwise alerts will sit in the queue unprocessed. If you don't have a worker, set ALERTSTREAM_QUEUE=false instead.

Preferred: give AlertStream its own named queue. This isolates alert jobs from your business jobs and lets you tune their worker independently:

If ALERTSTREAM_QUEUE_NAME is not set, jobs are pushed to the default queue and any existing worker that processes default will pick them up automatically with no extra configuration.

Queue off (sync, for simple setups or local dev)

All channel calls run synchronously in the same process. No worker needed. Suitable when you have no queue infrastructure, or for local development where you want to see alerts fire immediately without running a worker.

Note: even with ALERTSTREAM_QUEUE=false, each channel still fails silently in isolation, so one broken webhook will never crash the application.

Snapshots (opt-in)

Exception messages in Slack, Teams, Discord, or email are often truncated or hard to read. Snapshots solve this by persisting every exception to your database and including a secure, hash-based URL in every channel message. Click through to see the full stacktrace, context, and metadata in a clean web view.

Enabling snapshots

When enabled, AlertStream will:

When disabled (the default), none of the above happens. No migrations are loaded, nothing is written to the database, no routes exist.

Running the migration

Configuration

In config/alertstream.php you can also set route_middleware to protect the snapshots viewer (default: ['web']):

Security

Snapshot URLs use a 64-character SHA-256 hash, making them unguessable and non-sequential. If you need additional protection, add 'auth' or a custom middleware to route_middleware.

Pruning old snapshots

Snapshots are automatically eligible for pruning after 30 days (configurable via ALERTSTREAM_SNAPSHOTS_RETENTION), but you must schedule the pruning command yourself since Laravel packages cannot register scheduled tasks on behalf of the host application.

⚠️ Required: add one of the following to your scheduler, otherwise old snapshots will accumulate indefinitely.

Option 1 - Laravel's built-in model pruning (recommended if you already use it):

The Snapshot model uses MassPrunable, so Laravel discovers and prunes it automatically alongside any other prunable models in your app.

Option 2 - Dedicated AlertStream command:

Or run it manually:

Deleting individual snapshots

Each snapshot page includes a Delete button. Clicking it removes the snapshot immediately, which is useful when a snapshot contains sensitive information and you don't want to wait for automatic pruning.

Customising the snapshot view

This publishes the view to resources/views/vendor/alertstream/snapshots/show.blade.php where you can customise the layout, styling, and content.

Manual Usage

AlertStream provides two distinct ways to send messages:

report() log()
Purpose Exception alerts that need human attention Structured diagnostic / operational log messages
Writes to log channels
Dispatches to Slack, Teams, Discord, Mail
Creates snapshots ✅ (when enabled)
Subject to throttling / dedup
Accepts a Throwable ✅ (second argument)

report() - exception alerts

Use report() when something goes wrong and someone should know about it. The message is written to your configured Laravel log channels and dispatched to every active notification channel (Slack, Teams, Discord, Mail, or any custom channel). Snapshots, throttling, and deduplication all apply.

log() - structured logging at any level

For operational visibility, diagnostics, and auditing, use log(). It writes to your configured Laravel log channels only and does not trigger notifications, create snapshots, or go through throttling.

The $level parameter accepts any log level that Laravel supports (the standard PSR-3 levels):

Level Typical use
emergency System is unusable
critical Critical conditions
alert Action must be taken immediately
error Runtime errors that don't require immediate action
warning Exceptional occurrences that are not errors
notice Normal but significant events
info Interesting events (user login, scheduled job ran)
debug Detailed debug information

Examples:

A debug() convenience method is also available as a shorthand:

When should I use report() vs log()? Use report() when you have a caught exception and want the team notified via Slack/Teams/Discord/Mail. Use log() for everything else. It gives you structured, levelled logging through AlertStream's configured channels without triggering external notifications.

Dependency injection

Artisan test command

The --type flag accepts any log level string and defaults to alert (which triggers report()). Any other value is passed directly to log() at that level.

Throttling

Prevent alert storms when the same exception fires hundreds of times in a short window. Enable throttling to limit how many alerts per exception (same class + file + line) are sent per minute.

When the limit is hit, additional occurrences are silently dropped until the window resets. Snapshots (if enabled) still record every occurrence via dedup, but only the channel notifications are throttled.

Severity Mapping

AlertStream auto-detects severity based on exception type (PDOException -> critical, HttpResponseException -> warning, etc.). Override or extend this via severity_map in config:

The map is checked via instanceof, so parent classes cover their subclasses.

Context Enrichers

Add custom data to every alert without modifying AlertStream internals. Each enricher is an invokable class:

Register enrichers in config:

Enrichers run in order. If one throws, it is silently skipped and reporting continues with the remaining enrichers.

Snapshot Deduplication

When a snapshot already exists for the same exception (same class + file + line) within the configured window, AlertStream increments the existing snapshot's occurrence counter instead of creating a duplicate row.

Set to 0 to disable deduplication and create a new row for every exception.

The snapshot index view displays the occurrence count as a badge (e.g. "12x") and the detail view shows "Last seen" alongside the original timestamp.

Notification Channel

Use AlertStream as a native Laravel notification channel and compose alerts with the same API you already use for mail, SMS, database, etc.

Health Check Endpoint

A JSON endpoint is registered at GET /{route_prefix}/health to check AlertStream's runtime configuration. Useful for uptime monitors and deployment verification.

Response:

Configuration Reference

Core

Key Env Default Description
enabled ALERTSTREAM_ENABLED true Master on/off switch
report_exceptions ALERTSTREAM_REPORT_EXCEPTIONS true Auto-capture exceptions
level ALERTSTREAM_LEVEL alert Log level for Laravel log channels
log_channels ALERTSTREAM_LOG_CHANNELS single Laravel logging channels (comma-separated)
include_stacktrace ALERTSTREAM_INCLUDE_STACKTRACE true Attach full stack trace

Queue

Key Env Default Description
queue ALERTSTREAM_QUEUE true Hand off to a queue worker (faster)
queue_connection ALERTSTREAM_QUEUE_CONNECTION (app default) Queue connection
queue_name ALERTSTREAM_QUEUE_NAME default Queue name

Channels

Key Env Default Description
channels.active ALERTSTREAM_CHANNELS (none) Comma-separated list of active channels
channels.slack.webhook ALERTSTREAM_SLACK_WEBHOOK - Slack incoming webhook URL
channels.teams.webhook ALERTSTREAM_TEAMS_WEBHOOK - Teams incoming webhook URL
channels.discord.webhook ALERTSTREAM_DISCORD_WEBHOOK - Discord webhook URL
channels.mail.to ALERTSTREAM_MAIL_TO - Alert recipient address
channels.mail.from ALERTSTREAM_MAIL_FROM (mail.from) Sender address

Throttling

Key Env Default Description
throttle.enabled ALERTSTREAM_THROTTLE false Enable per-exception rate limiting
throttle.max_per_minute ALERTSTREAM_THROTTLE_MAX 5 Max alerts per minute per fingerprint

Severity & Enrichment

Key Type Description
severity_map array ExceptionClass::class => 'critical'\|'error'\|'warning'
context_enrichers array Invokable class FQCNs that augment every alert context

Snapshots

Key Env Default Description
snapshots.enabled ALERTSTREAM_SNAPSHOTS false Enable database snapshots
snapshots.table ALERTSTREAM_SNAPSHOTS_TABLE alertstream_snapshots Database table name
snapshots.retention_days ALERTSTREAM_SNAPSHOTS_RETENTION 30 Days before prune-eligible
snapshots.dedup_minutes ALERTSTREAM_SNAPSHOTS_DEDUP_MINUTES 60 Dedup window (0 = disabled)
snapshots.route_prefix ALERTSTREAM_SNAPSHOTS_ROUTE_PREFIX alertstream URL prefix
snapshots.route_middleware (config only) ['web'] Middleware for snapshot routes

Package Structure

Local Development

Test the package locally in another project using path repositories (changes are reflected instantly via symlink):

Development

The pre-commit hook runs php-cs-fixer automatically on every commit (installed via composer install).

License

MIT - see LICENSE.

Changelog

See CHANGELOG.md.


All versions of laravel-alertstream with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
laravel/framework Version ^10.0|^11.0|^12.0|^13.0
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 nightshift-foundry/laravel-alertstream contains the following files

Loading the files please wait ...