Download the PHP package theorchard/monolog-cascade without Composer

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

Monolog Cascade Build Status Coverage Status

What is Monolog Cascade?

Monolog Cascade is a Monolog extension that allows you to set up and configure multiple loggers and handlers from a single config file.

It's been inspired by the logging.config Python module.


Installation

Add monolog-cascade as a requirement in your composer.json file or run

Note: Monolog Cascade requires PHP 5.3.9 or higher.

Usage

Then just use your logger as shown below

Configuring your loggers

Monolog Cascade supports the following config formats:

Configuration structure

Here is a sample Yaml config file:

Here is a sample PHP config file:

More information on how the Cascade config parser loads and reads the parameters:

Only the loggers key is required. If formatters and/or handlers are ommitted, Monolog's default will be used. processors is optional and if ommitted, no processors will be used. (See the "Optional Keys" section further below).

Other keys are optional and would be interpreted as described below:

Note: If you would like to use objects as parameters for your handlers, you can pass a class name (using the class option) with the corresponding arguments just like you would configure your handler. Cascade recursively instantiates and loads those objects as it parses the config file. See this sample config file.

Parameter case

You can use either underscored or camelCased style in your config files, it does not matter. However, it is important that they match the names of the arguments from the constructor method.

Using a Yaml file:

Cascade will camelCase all the names of your parameters internally prior to be passed to the constructors.

Optional keys

formatters, handlers and processors keys are optional. If ommitted Cascade will default to Monolog's default formatter and handler: Monolog\Formatter\LineFormatter and Monolog\Handler\StreamHandler to stderr. If processors is ommitted, your logger(s) won't use any.

Default parameters

If a constructor method provides default value(s) in their declaration, Cascade will look it up and identify those parameters as optional with their default values. It can therefore be ommitted in your config file.

Order of sections and params

Order of the sections within the config file has no impact as long as they are formatted properly.
Order of parameters does not matter either.

Extra parameters (other than constructor's)

You may want to have your Formatters and/or Handlers consume values other than via the constructor. Some methods may be called to do additional set up when configuring your loggers. Cascade interprets those extra params 3 different ways and will try do so in that order:

  1. Instance method
    Your Formatter or Handler has a defined method that takes a param as input. In that case you can write it as follow in your config file:

    In this example, the LineFormatter class has an includeStacktraces method that takes a boolean. This method will be called upon instantiation.

  2. Public member
    Your Formatter or Handler has a public member that can be set.

    In this example, the public member will be set to the passed in value upon instantiation.

  3. Custom handler function
    See FormatterLoader::initExtraOptionsHandlers and HandlerLoader::initExtraOptionsHandlers. Those methods hold closures that can call instance methods if needed. The closure takes the instance and the parameter value as input.

    You can add handlers at runtime if needed. (i.e. if you write your logger handler for instance)

Running Tests

Just run Phpunit:

Contributing

This extension is open source. Feel free to contribute and send a pull request!

Make sure your code follows the PSR-2 standards, is documented and has unit tests.

What's next?

Symfony Users

You may want to use MonologBundle as it integrates directly with your favorite framework.

Under The Hood

Here is a Medium post if you want to know more about the implementation.


All versions of monolog-cascade with dependencies

PHP Build Version
Package Version
Requires php Version >=7.2
symfony/config Version ^2.7 || ^3.0 || ^4.0 || ^5.0
symfony/options-resolver Version ^2.7 || ^3.0 || ^4.0 || ^5.0
symfony/serializer Version ^2.7 || ^3.0 || ^4.0 || ^5.0
symfony/yaml Version ^2.7 || ^3.0 || ^4.0 || ^5.0
monolog/monolog Version ^1.13 || ^2.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 theorchard/monolog-cascade contains the following files

Loading the files please wait ....