Download the PHP package eth8505/laminas-monolog without Composer

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

LaminasMonolog - Laminas module integrating monolog with laminas

The LaminasMonolog module integrates monolog/monolog as a laminas module via laminas/laminas-servicemanager.

CI Status Packagist Packagist Version PHP from Packagist

How to install

:warning: Please note that this package requires at least php 7.3.
Install eth8505/laminas-monolog package via composer.

$ composer require eth8505/laminas-monolog

Load the module in your application.config.php file like so:

<?php

return [
    'modules' => [
        'LaminasMonolog',
        // ...
    ],
];

How to use

In your application config (usually located in config/autoload/monolog.global.php), specify your monolog in the monolog/loggers key.

Configuring loggers

Each key ( in the sample code) can contain a separate logger config and is available directly via the service manager.

return [
    'monolog' => [
        'loggers' => [
            'Log\MyApp' => [
                'name' => 'default'
            ]
        ]
    ]
];

Each logger config is available direcly via the service manager.

$logger = $container->get('Log\MyApp');

Adding log handlers

Multiple handlers can be added to a logger config via the key.

return [
    'monolog' => [
        'loggers' => [
            'Log\MyApp' => [
                'name' => 'default',
                'handlers' => [
                    'stream' => [
                        'name' => StreamHandler::class,
                        'options' => [
                            'path'   => 'data/log/myapp.log',
                            'level'  => Logger::DEBUG
                        ],
                    ],
                    'fire_php' => [
                        'name' => ChromePHPHandler:class
                    ]
                ]
            ]
        ]
    ]
];

Using formatters

Each handler can be configured with a formatter in order to specify a specific format. This can be useful whenlogging to logstash for example.

return [
    'monolog' => [
        'loggers' => [
            'Log\MyApp' => [
                'name' => 'default',
                'handlers' => [
                    'stream' => [
                        'name' => StreamHandler::class,
                        'options' => [
                            'path'   => 'data/log/myapp.log',
                            'level'  => Logger::DEBUG
                        ],
                        'formatter' => [
                            'name' => LogstashFormatter::class,
                            'options' => [
                                'applicationName' => 'myApp',
                                'systemName' => gethostname()
                            ]
                        ]
                    ]
                ]
            ]
        ]
    ]
];

Using processors

Processors can be used to enrich the logged data with additional data. The WebProcessor can for example be used to add the request URI and client IP to the log record.

return [
    'monolog' => [
        'loggers' => [
            'Log\MyApp' => [
                'name' => 'default'
                'processors' => [
                    WebProcessor::class
                ]
            ]
        ]
    ]
];

Special syntax

When configuring handlers, formatters or processors, you can either specify a class name in string (or ::class constant) format

return [
    'monolog' => [
        'loggers' => [
            'Log\MyApp' => [
                'name' => 'default'
                'processors' => [
                    WebProcessor::class
                ]
            ]
        ]
    ]
];

or alternatively in name/options array notation, where the options are translated into the respective classes constructor parameters by using Reflection based Named parameters.

return [
    'monolog' => [
        'loggers' => [
            'Log\MyApp' => [
                'name' => 'default'
                'processors' => [
                    [
                        'name' => WebProcessor::class,
                        'options' => [
                            'extraFields' => [
                                'url' => 'REQUEST_URI',
                                'http_method' => 'REQUEST_METHOD',
                                'server' => 'SERVER_NAME'
                            ]
                        ]
                    ]
                ]
            ]
        ]
    ]
];

Custom handlers, processors and formatters

Since this module creates everything via the service manager using plugin managers, custom handlers, processors and formatters can be easily registered, by adding them to the respective config keys

return [
    'monolog' => [
        'formatters' => [
            factories' => [
                MyCustomFormatter::class => MyCustomFormatterFactory::class
            ]
        ],
        'handlers' => [
            'factories' => [
                MyCustomHandler::class => MyCustomHandlerFactory::class
            ]
        ],
        'processors' => [
            'factories' => [
                MyCustomProcessor::class => MyCustomProcessorFactory::class
            ]
        ]
    ]
];

:warning: Note that only formatters using custom factories need to be explicitly registered. Any other handler configured will be automatically created using the internal, reflection-based factories.

Extending log handlers

You can define default loggers and inherit from them in other loggers.

return [
    'monolog' => [
        'loggers' => [
            'base' => [
                // default logger config
            ],
            'inherited' => [
                '@extends' => 'base'
            ]
        ]
    ]
];

:information_source: Even though recursion is supported here as of Version 1.0.3, it is limited to 10 levels and will throw a if recursed any deeper.

See example config for details.

Thanks

Thanks to neckeloo and his Monolog Module and enlitepro for their Enlite Monolog as they served as a template for this module.


All versions of laminas-monolog with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
monolog/monolog Version ^3.0
laminas/laminas-servicemanager Version ^3.0
laminas/laminas-stdlib Version ^3.2
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 eth8505/laminas-monolog contains the following files

Loading the files please wait ....