Download the PHP package oras/monolog-middleware without Composer

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

Build Status Latest Stable Version Total Downloads License

Monolog Logger Middleware

Monolog Middleware to be used with PSR-7 middleware frameworks like Zend Expressive and Slim.

*Now it does support Zend Expressive `3.`**

To use with Zend Expressive 1.* please install version 1.1.4 To use with Zend Expressive 2.* please install version 2.0.0

loggables setting inspired by Guzzle Log Format. You can set any data in request/response/headers that you want to log from config file rather than in code to give more flexibility in logging more/less data based on your needs.

Installation

1) Install middleware using composer
2) Add configuration

Then in your Zend Expressive config/autoload/ directory, created a new config file call it: logger.local.php

As a starting point, you can have the following in the file:

Please refer to Loggables list at end for all possible variables.

3) Add factory and middleware to dependencies.global.php file as follows:
4) Now to start recording logs of request/response for a middleware, just put the following line after routing.

Example:

Now every time you call the route /, you'll get logs for request and response.

By default, MonologMiddleware will record logs in debug mode. If you want to handle different levels, just change level in config.

Requirements

Configuration examples

Full example of each implemented handler in Monolog Middleware. Please note that these might not be ALL handlers supported by Monolog, they are just the implemented in this middleware.

All lines are required unless stated.

Stream
Loggly
Slack
Pushover
Native Email handler
Browser Console handler
Redis handler
FirePHP handler
NewRelic handler

Loggables list

To log request/response body you can use {req_body} and {res_body} respectively in format setting.

Full list of logs variables with description:

Variable Substitution
{request} Full HTTP request message
{response} Full HTTP response message
{ts} Timestamp
{host} Host of the request
{method} Method of the request
{url} URL of the request
{host} Host of the request
{protocol} Request protocol
{version} Protocol version
{resource} Resource of the request (path + query + fragment)
{port} Port of the request
{hostname} Hostname of the machine that sent the request
{code} Status code of the response (if available)
{phrase} Reason phrase of the response (if available)
{curl_error} Curl error message (if available)
{curl_code} Curl error code (if available)
{curl_stderr} Curl standard error (if available)
{connect_time} Time in seconds it took to establish the connection (if available)
{total_time} Total transaction time in seconds for last transfer (if available)
{reqheader*} Replace * with the lowercased name of a request header to add to the message
{resheader*} Replace * with the lowercased name of a response header to add to the message
{req_body} Request body
{res_body} Response body

Extending Middleware

To extend the middleware to log your own format, or specific data like cookies, server params .. etc. You can do that easily using the following steps:

  1. Create a factory class. I have named it MyMonologMiddlewareFactory which will call a MyMonologMiddleware class which will be your customised middleware to log.

  2. Create Middleware class

  3. Add your factory and middleware to global dependency file. Assuming you have your middleware and factory in the same directory, the config will be:

That's it ... you're ready to use your own customised logger.

Monolog Middleware was written during my commute time. Written with passion on SouthWest Trains. Please mind the gap!


All versions of monolog-middleware with dependencies

PHP Build Version
Package Version
Requires php Version ^7.1 || ^7.2
monolog/monolog Version ^1.19
psr/http-message Version ~1.0.0
symfony/http-foundation Version ^3.0
guzzlehttp/psr7 Version ^1.3 || ^1.4
psr/http-server-middleware Version ^1.0
psr/container Version ^1.0
zendframework/zend-stratigility Version ^3.0
roave/security-advisories Version dev-master
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 oras/monolog-middleware contains the following files

Loading the files please wait ....