Download the PHP package faustoff/laravel-contextify without Composer

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

Packagist Version Packagist Downloads Packagist License GitHub Repo stars

Laravel Contextify

Contextual logging with inline notifications for Laravel.

Laravel Contextify enhances Laravel's logging with two main features:

  1. Inline Notifications — send notifications alongside logging without splitting code into multiple lines for logging and notifying.
  2. Automatic Context Enrichment — logs and notifications include extra contextual data from configured Call file and line, and more), helping you keep messages short and clean by moving additional context out of the message itself into a separate area.

Provides Log facade: same methods (debug, info, notice, warning, error, critical, alert, emergency) with identical parameters, plus a chainable notify() method.

Name origin: “Contextify” combines Context and Notify, reflecting its dual purpose — to enrich logs with contextual data and to send notifications for log events.

Features

Requirements

Installation

Install the package via Composer:

Configuration

Optionally, publish the configuration file:

This creates config/contextify.php for configuring notifications.

Environment Variables

Add to .env to configure notification recipients and toggles:

Set CONTEXTIFY_ENABLED=false to fully disable Contextify: no context providers are booted, the Monolog processor is not registered, exception reporting is not hooked, notify() calls are ignored, and touch() becomes a no-op. Logging methods (debug, info, etc.) still forward messages to Laravel's Log facade, but without any context enrichment. This is useful for disabling Contextify during testing to eliminate its influence on the code under test.

Set CONTEXTIFY_NOTIFICATIONS_ENABLED=false to disable all notifications (both inline notify() and automatic exception notifications).

Note: CONTEXTIFY_ENABLED disables the entire package. CONTEXTIFY_NOTIFICATIONS_ENABLED only disables notifications while keeping context enrichment active.

Note: Telegram notifications require the laravel-notification-channels/telegram package to be installed manually.

Usage

Writing Logs

Use the for logging:

Sending Notifications

Chain notify() after any for notifications.

Filter channels using only and except parameters:

Control notification sending conditionally using the shouldNotify parameter:

If necessary, you can override the default implementation of the LogNotification:

Update configuration:

Exception Notifications

Exceptions are automatically reported via notifications (enabled by default). Notifications include exception details (message and stack trace) and extra context from for notifications.

If necessary, you can override the default implementation of the ExceptionNotification:

Update configuration:

To disable automatic exception notifications, set reportable to null:

Note: ExceptionNotificationFailedException prevents infinite loops when exception notifications fail.

Context Providers

Context Providers add extra contextual data to logs and notifications, helping you keep log entry and notification messages short and clean by moving additional context out of the message itself into a separate context area. The contextual data is still present in the log entry or notification, but it's separated from the message itself—keeping the message focused while preserving all information for searching and analysis. You no longer need to worry about explicitly passing the required contextual data each time, as it will be added automatically.

Static Context Providers

Static providers return data that remains constant throughout the request/process lifecycle. They implement StaticContextProviderInterface.

Built-in:

Refreshing Static Context

Static context is cached during application boot. Use touch() to refresh it manually, useful when a process is forked (e.g., queue workers) to generate a new trace ID:

Dynamic Context Providers

Dynamic providers refresh data on each log call. They implement DynamicContextProviderInterface.

Built-in:

Creating Custom Context Providers

Implement StaticContextProviderInterface or DynamicContextProviderInterface:

Registering Custom Providers

Add custom providers to config/contextify.php:

Group-Based Context

Define separate Context Providers for logs and notifications. If a provider appears in both sets, the same context data is used for both.

Configure in config/contextify.php:

Example:

Notifications

Supports mail and telegram channels out of the box. Mail works immediately; Telegram requires the laravel-notification-channels/telegram package.

Configuration

Configure channels in config/contextify.php:

Custom Notification Channels

For example, to add Slack notifications, you need to:

  1. Create a custom notification class with a toSlack() method implemented:

  2. Create a custom notifiable class with a routeNotificationForSlack() method implemented:

  3. Configure Slack in config/services.php.

  4. Update config/contextify.php:

Note: For exception notifications, extend ExceptionNotification and add the toSlack() method similarly.

Want more notification channels? You are welcome to Laravel Notifications Channels.

Console Commands

Tracking

Use Faustoff\Contextify\Console\Trackable trait to log command start, finish, and execution time:

Log:

Output Capturing

Use Faustoff\Contextify\Console\Outputable trait to capture Laravel console output from info()-like methods and store it in logs:

Log:

Handling Shutdown Signals

Handle shutdown signals (SIGQUIT, SIGINT, SIGTERM by default) for graceful shutdown. Use the appropriate trait with SignalableCommandInterface:

Log:

License

This package is open-sourced software licensed under the MIT license.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Support

For issues, questions, or contributions, please visit the GitHub repository.


All versions of laravel-contextify with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
illuminate/contracts Version ^9.0|^10.0|^11.0|^12.0
illuminate/log Version ^9.0|^10.0|^11.0|^12.0
illuminate/notifications Version ^9.0|^10.0|^11.0|^12.0
illuminate/support Version ^9.0|^10.0|^11.0|^12.0
monolog/monolog Version ^2.0|^3.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 faustoff/laravel-contextify contains the following files

Loading the files please wait ...