Download the PHP package gupalo/monolog-dbal-logger without Composer

On this page you can find all versions of the php package gupalo/monolog-dbal-logger. 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 monolog-dbal-logger

Monolog Handler for DBAL

Installation

Add to your project via composer:

composer require gupalo/monolog-dbal-logger

Create log table.

CREATE TABLE `_log` (
    `id`                    bigint UNSIGNED NOT NULL AUTO_INCREMENT,
    `created_at`            datetime NOT NULL,
    `level`                 smallint NOT NULL DEFAULT 0,
    `level_name`            enum('debug','info','notice','warning','error','critical','alert','emergency') NULL DEFAULT NULL,
    `channel`               varchar(255) NOT NULL DEFAULT '',
    `message`               varchar(1024) NOT NULL DEFAULT '',
    `context`               text NULL DEFAULT NULL,
    PRIMARY KEY (`id`),
    INDEX `log_created_at_level` (`created_at`, `level`) USING BTREE
) DEFAULT CHARACTER SET=utf8mb4 COLLATE=utf8mb4_general_ci;

Example

$connection is Doctrine\DBAL\Connection

$handler = new \Gupalo\MonologDbalLogger\MonologDbalLogger($connection);
$logger = new \Monolog\Logger();
$logger->pushHandler($handler);

$logger->addWarning('You might not read the docs', ['page' => 17, 'username' => 'guest']);

Symfony

Configuration example:

services.yaml

Gupalo\MonologDbalLogger\Symfony\ErrorLogListener:
    tags: [ {name: 'kernel.event_subscriber'} ]

monolog.dbal_handler:
    class: 'Gupalo\MonologDbalLogger\MonologDbalLogger'
    public: true
    bind:
        $connection: '@doctrine.dbal.default_connection'
        $level: 200
    tags: ['monolog.logger']

monolog.yaml

monolog:
    handlers:
        db:
            type: service
            id: 'monolog.dbal_handler' # note - no "@"
            channels: ["!event", "!request", "!security"]

Configure

Params in MonologDbalLogger::__construct:

Extend

You may extend MonologDbalLogger and add your own logic. See MyMonologDbalLogger as an example. If you add additional fields, don't forget to change table creation SQL.

Table:

CREATE TABLE `_log` (
    `id`                    bigint UNSIGNED NOT NULL AUTO_INCREMENT,
    `created_at`            datetime NOT NULL,
    `level`                 smallint NOT NULL DEFAULT 0,
    `level_name`            enum('debug','info','notice','warning','error','critical','alert','emergency') NULL DEFAULT NULL,
    `channel`               varchar(255) NOT NULL DEFAULT '',
    `message`               varchar(1024) NOT NULL DEFAULT '',
    `context`               text NULL DEFAULT NULL,
    `method`                varchar(255) NULL DEFAULT NULL,
    `cmd`                   varchar(255) NULL DEFAULT NULL,
    `uid`                   varchar(32) NULL DEFAULT NULL,
    `count`                 int NULL DEFAULT NULL,
    `time`                  float NULL DEFAULT NULL,
    `exception_class`       varchar(1024) NULL DEFAULT NULL,
    `exception_message`     varchar(1024) NULL DEFAULT NULL,
    `exception_line`        varchar(1024) NULL DEFAULT NULL,
    `exception_trace`       text NULL,
    PRIMARY KEY (`id`),
    INDEX `log_created_at_level` (`created_at`, `level`) USING BTREE
) DEFAULT CHARACTER SET=utf8mb4 COLLATE=utf8mb4_general_ci;

Other

See tests.


All versions of monolog-dbal-logger with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
ext-json Version *
ext-mbstring Version *
doctrine/dbal Version ^3.8|^4.0
monolog/monolog Version ^3.5
symfony/console Version ^5.4|^6.0|^7.0
symfony/event-dispatcher Version ^5.4|^6.0|^7.0
symfony/http-kernel Version ^5.4|^6.0|^7.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 gupalo/monolog-dbal-logger contains the following files

Loading the files please wait ....