Download the PHP package code-distortion/clarity-context without Composer

On this page you can find all versions of the php package code-distortion/clarity-context. 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 clarity-context

Clarity Context - Understand Your Exceptions

Latest Version on Packagist PHP Version Laravel GitHub Workflow Status Buy The World a Tree

code-distortion/clarity-context is a Context Tracker package for Laravel that gives you a birds-eye-view of what your code was doing when an exception occurs.

Add context to your code. e.g.

This information is collected so when an exception occurs, it can be used to show what your code was doing at the time. e.g.


Clarity Suite

Clarity Context is a part of the Clarity Suite, designed to let you manage exceptions more easily:


Table of Contents

Installation

Install the package via composer:

Config File

Use the following command if you would like to publish the config/code_distortion.clarity_context.php config file.

It simply gives you the option to turn this package on or off.

Add Context to Your Code

Clarity Context lets you add context details throughout your code. It keeps track of what's currently in the call stack, ready for when an exception occurs. e.g.

You can add strings to explain what's currently happening in a sentence, or associative arrays to show specific details about what your code is currently working with.

Add context throughout your code in relevant places. Pick places that will give you the most insight when tracking down a problem. Add as many as you feel necessary.

You can pass multiple values at once:

Note: Don't add sensitive details that you don't want to be logged!

If you use trace identifiers to identify requests, you can add these as well. A good place to add them would be in a service provider or request middleware.

Exception Logging

To log your exceptions, install a package like Clarity Logger that's aware of Clarity Context. Follow its installation instructions to add logging to your project.

Clarity Logger will automatically include your context details alongside the details it normally logs. e.g.

⚙️ Click for more information. ## Logging Exceptions (Advanced) Clarity Context collects and manages the context details you've added to your code. When an exception occurs, it builds a `CodeDistortion\ClarityContext\Context` object that can be used by the code doing the logging. This `Context` object contains the details you added (that were present in the call stack at the time). If you'd like to handle the logging yourself, or are building a package to do so - this involves updating Laravel's [exception handler](https://laravel.com/docs/10.x/errors#the-exception-handler) `app/Exceptions/Handler.php` to use these `Context` values. This section explains how to use this `Context` class. ### Obtaining the Context Object Use `Clarity::getExceptionContext($e)` to access the `CodeDistortion\ClarityContext\Context` object built for that exception. Then you can choose how to log the exception based on what's inside the `Context` object. ### The Context Object The `Context` object includes a variety of details about the exception, including: - the call stack / stack trace (based on `$e->getTrace()`, but with the file/line numbers shifted by one frame, so they make more sense), - your context details, that were present in the call stack at the time the exception occurred, - references to the location where the exception was thrown and caught. #### Stack Trace / Call Stack, and Frames You can retrieve details about the call stack frames using `$context->getStackTrace()` or `$context->getCallStack()`. They contain objects representing each frame. `getStackTrace()` contains the frames in order from most recent to oldest. `getCallStack()` is the same, except ordered from oldest to newest. They also contain the following methods to help you find particular frames and meta information. They are iterable, allowing them to be looped through. You can retrieve the following details from the Frame objects inside: > ***Note:*** Some of the methods like `getFunction()`, `getClass()`, `getObject()` won't always return a value. It depends on the circumstance. See [PHP's debug_backtrace method](https://www.php.net/manual/en/function.debug-backtrace.php) for more details. #### Meta Objects There are 5 types of Meta objects: - `ContextMeta` - when the application called `Clarity::context(…)` to add context details, - `CallMeta` - when the Control package ran some code for the application (e.g. using `Control::run()`), - `LastApplicationFrameMeta` - the location of the last application (i.e. non-vendor) frame, - `ExceptionThrownMeta` - the location the exception was thrown, - `ExceptionCaughtMeta` - the location the exception was caught. You can retrieve the following details from the Meta objects: There are several ways of retrieving Meta objects: Each of these methods accepts a meta-class string, or several of them, which limit the result. e.g. #### MetaGroup Objects When reporting the exception details, it's useful to group the Meta objects together. `MetaGroup` objects provide a way of grouping the Meta objects in a logical way. The Meta objects within are related, i.e. in the same frame and on near-by lines. Each MetaGroup contains similar details to the `Frame` object. ### Context Objects Without an Exception You can generate a Context object arbitrarily, without needing an exception. The Context object returned will contain the current context details, like it normally would.


Testing This Package

Changelog

Please see CHANGELOG for more information on what has changed recently.

SemVer

This library uses SemVer 2.0.0 versioning. This means that changes to X indicate a breaking change: 0.0.X, 0.X.y, X.y.z. When this library changes to version 1.0.0, 2.0.0 and so forth, it doesn't indicate that it's necessarily a notable release, it simply indicates that the changes were breaking.

Treeware

This package is Treeware. If you use it in production, then we ask that you buy the world a tree to thank us for our work. By contributing to the Treeware forest you’ll be creating employment for local families and restoring wildlife habitats.

Contributing

Please see CONTRIBUTING for details.

Code of Conduct

Please see CODE_OF_CONDUCT for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of clarity-context with dependencies

PHP Build Version
Package Version
Requires php Version 8.0.* | 8.1.* | 8.2.* | 8.3.*
code-distortion/staticall Version ^0.1.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 code-distortion/clarity-context contains the following files

Loading the files please wait ....