导航菜单
首页 >  laravel  > Context

Context

ContextIntroductionHow it WorksCapturing ContextStacksRetrieving ContextDetermining Item ExistenceRemoving ContextHidden ContextEventsDehydratingHydratedIntroduction

Laravel's "context" capabilities enable you to capture, retrieve, and share information throughout requests, jobs, and commands executing within your application. This captured information is also included in logs written by your application, giving you deeper insight into the surrounding code execution history that occurred before a log entry was written and allowing you to trace execution flows throughout a distributed system.

How it Works

The best way to understand Laravel's context capabilities is to see it in action using the built-in logging features. To get started, you may add information to the context using the Context facade. In this example, we will use a middleware to add the request URL and a unique trace ID to the context on every incoming request:

相关推荐: