creamio/symfony_basebundle

Core bundle for CreamIO bundles in symfony

Installs: 155

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 1

Forks: 0

Open Issues: 0

Type:symfony-bundle


README

This bundle is a base for the CreamIO symfony bundles over Symfony 4.0.

Requirements

Installation

Require the bundle from a symfony 4 application.

You must configure the logger channel to log to database by modifying config/packages/(dev|prod)/monolog.yaml this way :

    channels: ['db']
    handlers:
        db:
            channels: ['db']
            type: service
            id: cream_io_base.loggingservice

You MUST NOT modify anything in this configuration, as the services are injected in the bundle for logger providing.

Usage

Autowire or inject CreamIO\BaseBundle\Service\LoggerProvider in your service/controller.
You can then log this way :

$logger = $loggerProvider->logger();
$logger->info('My information to log', ['userId', $user->getId()]);    

The second parameter is the context, it can be an array of whatever you want to identify the logging context.

Project tree

.
└── src
    ├── DependencyInjection
    ├── EventSubscriber     # Exception event subscriber
    ├── Exceptions          # APIError and APIException for error handling in API
    ├── Resources
    │   └── config          # Service injection
    └── Service             # API Service handling JSON responses

License

Creative Commons License

This software is distributed under the terms of the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International Public License. License is described below, you can find a human-readable summary of (and not a substitute for) the license here.