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 in Laravel

This package allows you to write log messages fitted with the execution context, including the class, PID, UID (and more), directly from your application PHP classes. It provides a PHP trait that allows you to achieve this. Additionally, it provides various enhancements to the native Laravel Logging functionality.

Adding execution context to logs very helpful when your application has grown in size and complexity, and you begin to facing a large number of logs originating from various parts of the application, including multiple processes such as queue workers and daemons.

By examining the class of a log record, you can easily determine its source. It also groups together all log records associated with that class.

The PID groups all log records related to a specific process, such as a queue worker or daemon.

The UID combines all log records associated with the processing of a single user request or, for instance, the execution of a single console command.

The MEM indicates the amount of memory allocated from system (including unused pages) to PHP at the time of adding a log record.

Log records will be looks like this:

[2023-03-07 19:26:26] local.NOTICE: [App\Services\OrderService] [PID:56] [UID:640765b20b1c0] [MEM:31457280] Order was created

In addition, this package allows to:

Installation

composer require faustoff/laravel-contextify:^2.0

Publishing config file

Optionally, you can publish the health config file with this command:

php artisan vendor:publish --tag="contextify-config"

Usage

Contextual Logging

Suppose you have kind of OrderService in your application.

To add contextual logging to OrderService use Faustoff\Contextify\Loggable trait and methods like $this->logInfo() which trait provides:

Log:

Parent Context

If you have multiple levels of logging context you can pass "parent" loggable to "child" by using Faustoff\Loggable\HasLog trait.

Suppose you have "parent" logging context OrderController and "child" OrderService and you want to pass OrderController logging context to OrderService.

Log:

Notifications

Out of the box, the notification can be sent via:

If you want to send Email notifications you should configure CONTEXTIFY_MAIL_ADDRESSES environment variable. You can pass multiple addresses by separating them with commas like this:

If you want to send Telegram notifications you should install and configure laravel-notification-channels/telegram package. Then you should set CONTEXTIFY_TELEGRAM_CHAT_ID environment variable with retrieved Telegram Chat ID.

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

Also, you can override which queue (default queue by default) will be used to send a specific notification through a specific channel. This will be done in contextify config by key notifications.list like this:

You can completely disable notifications by CONTEXTIFY_NOTIFICATIONS_ENABLED environment variable.

Log Notifications

To send log notification you should set third parameter of logInfo()-like methods to true:

Exception Notifications

You will receive notifications about any unhandled reportable exceptions.

To turn off, set empty value to notifications.exception_handler.reportable key of contextify configuration file.

Console Commands

If you wants to add contextual logging in to console commands, you can use Faustoff\Contextify\Console\Loggable trait. It extends common Faustoff\Contextify\Loggable by writing logs to console output (terminal).

Log:

Terminal output:

Console Command Tracking

Also, you can track console command execution by using Faustoff\Contextify\Console\Trackable trait. It adds additional debug log entries when console commands starts and finish with execution time and peak memory usage.

Log:

Terminal output:

Console Command Output Capturing

Also, you can capture native Laravel console command output, produced by info()-like methods, and store it to logs by using Faustoff\Contextify\Console\Outputable trait:

Log:

Terminal output:

Console Command Handling Shutdown Signals

You can handle shutdown signals (SIGQUIT, SIGINT and SIGTERM by default) from Console Command to graceful shutdown command execution by using Faustoff\Contextify\Console\Terminatable trait and Symfony\Component\Console\Command\SignalableCommandInterface interface together:


All versions of laravel-contextify with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
nesbot/carbon Version ^2.0|^3.0
monolog/monolog Version ^2.0|^3.0
illuminate/log Version ^8.0|^9.0|^10.0|^11.0
illuminate/notifications Version ^8.0|^9.0|^10.0|^11.0
illuminate/support Version ^8.0|^9.0|^10.0|^11.0
vlucas/phpdotenv Version ^5.4.1
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 ....