Download the PHP package onlime/laravel-http-client-global-logger without Composer

On this page you can find all versions of the php package onlime/laravel-http-client-global-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 laravel-http-client-global-logger

Laravel HTTP Client Global Logger

Latest Version on Packagist Packagist Downloads PHP from Packagist Build Status GitHub License

A super simple global logger for the Laravel HTTP Client.

Installation

You can install the package via Composer:

Configuration

This is a zero-configuration package. It is auto-discovered by Laravel and global logging is enabled by default. No further configuration needed - you may skip directly to the Usage section below.

Optionally publish the config file with:

You may override its configuration in your .env - the following environment vars are supported:

(look into config/http-client-global-logger.php for defaults, further configuration, and explanation)

Features

Using the logger will log both the request and response of an external HTTP request made with the Laravel HTTP Client.

Usage

NOTE: For all 3 variants below, you need to keep the HTTP Client Global Logger enabled (not setting HTTP_CLIENT_GLOBAL_LOGGER_ENABLED=false in your .env). The http-client-global-logger.enabled config option is a global on/off switch for all 3 variants, not just the "global" variants. Our project name might be misleading in that context.

Variant 1: Global Logging

Just use Laravel HTTP Client as always - no need to configure anything!

Slightly more complex example:

Variant 2: Mixin Variant

If you enable mixin variant, global logging will be turned off. Put this into your .env:

You could then turn on logging individually on each HTTP Client instance, using the log() method:

Logging with custom channel name (if not specified, defaults to current environment, such as production or local):

Slightly more complex example:

Variant 3: Global HTTP Middleware

If you use Global Middleware (Http::globalRequestMiddleware() and Http::globalResponseMiddleware() methods), you should be aware that Variant 1 uses Laravel's RequestSending event to log HTTP requests. This event is fired before Global Middleware is executed. Therefore, any modifications to the request made by Global Middleware will not be logged. To overcome this, this package provides a middleware that you may add after your Global Middleware.

You may add the middleware using the static addRequestMiddleware() method on the HttpClientLogger class:

For example, you may add this to your AppServiceProvider's boot() method after registering your Global Middleware:

Logging example

By default, logs are written to a separate logfile http-client.log.

Log entry example:

FAQ

How does this package differ from bilfeldt/laravel-http-client-logger ?

Honestly, I did not really look into bilfeldt/laravel-http-client-logger, as my primary goal was to build a global logger for Laravel HTTP Client without any added bulk. Global logging currently (as of July 2021) is still an open issue, see bilfeldt/laravel-http-client-logger#2 - Add global logging.

Both packages provide a different feature set and have those advantages:

So, my recommendation: If you need global logging without any extra configuration and without changing a line of code in your project, go for my package. If you don't want to log everything and wish to filter by HTTP response code, go for Bilfeldt's package. But don't install both!

Caveats

Testing

Currently, there is very basic code/test coverage. We're using PEST, so just run all tests like so:

Changes

All changes are listed in CHANGELOG

Authors

Made with ❤️ by Philip Iezzi (Onlime GmbH).

License

This package is licenced under the MIT license however support is more than welcome.


All versions of laravel-http-client-global-logger with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
illuminate/http Version ^10.32|^11.0
illuminate/support Version ^10.0|^11.0
monolog/monolog Version ^3.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 onlime/laravel-http-client-global-logger contains the following files

Loading the files please wait ....