Download the PHP package linkorb/app-event-bundle without Composer
On this page you can find all versions of the php package linkorb/app-event-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download linkorb/app-event-bundle
More information about linkorb/app-event-bundle
Files in linkorb/app-event-bundle
Package app-event-bundle
Short Description Application Event logging for Symfony Applications
License MIT
Informations about the package app-event-bundle
linkorb/app-event-bundle
Integrates and provides a handy configuration for linkorb/app-event and its standard scheme for logging Application Events.
Installation
Applications that use Symfony Flex
Open a command console, enter your project directory and execute:
Applications that don't use Symfony Flex
Step 1: Download the Bundle
Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:
This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.
Step 2: Enable the Bundle
Then, enable the bundle by adding it to the list of registered bundles
in the config/bundles.php
file of your project:
Usage
The bundle will automatically inject a special App Event logger into services and controllers which implement AppEventLoggerAwareInterface. There are a few ways to achieve this.
Use AppEventLoggerTrait which provides an implementation of both AppEventLoggerAwareInterface and AppEventLoggerInterface:
If your Controllers extend Symfony's AbstractController you can instead make them extend AppEventLoggingController which does the above for you and also extends Symfony's AbstractController:
Your services can extend AppEventLoggingService to get the same benefit:
Configuration
You need to create a Monolog configuration for each of the environments in which the bundle is enabled (which by default is all of them). Put this in each of the Monolog config files:
In the above config, we instruct Symfony's Monolog Bundle to create an
additional Logger service with the name monolog.logger.app_event
and to
create an instance of Monlog's StreamHandler which will be used by our logger
to write to the file at path
. The minimum logging level for our logger is
set to INFO. This is the minimum you need to do to configure the logger, but
there are a few extra things you can configure.
The following configurations can be set independently in each environment, for
example you could place the directives in a file named
config/packages/prod/linkorb_app_event.yaml
. If the bundle has been enabled
in every environment then you can configure it simultaneously for all
environments in config/packages/linkorb_app_event.yaml
.
You can turn off the TokenProcessor which automatically adds information to App events about the authenticated user:
You can turn on the TagProcessor which will add your tags to App events:
Finally there are a few things you can configure that you are unlikely to need.
You can change the name of the logging channel from the default app_event
:
Remember to use this channel name instead of app_event
in the Monolog config
files.
You can also change the name of the logging handler from the default
app_events
:
Remember to use this handler name instead of app_events
in the Monolog config
files.
Happy Application Event Logging!
All versions of app-event-bundle with dependencies
linkorb/app-event Version ^2.0
monolog/monolog Version ^1.24 || ^2
psr/log Version ^1.1
symfony/config Version ^5.4 || ^6.0
symfony/dependency-injection Version ^5.4 || ^6.0
symfony/framework-bundle Version ^5.4 || ^6.0
symfony/http-kernel Version ^5.4 || ^6.0
symfony/monolog-bridge Version ^5.4 || ^6.0
symfony/security-core Version ^5.4 || ^6.0
symfony/yaml Version ^5.4 || ^6.0