Download the PHP package mtownsend/laravel-request-response-logger without Composer

On this page you can find all versions of the php package mtownsend/laravel-request-response-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-request-response-logger

Easily capture every incoming request and the corresponding outgoing response in your Laravel app.

This package is designed to work only with the Laravel framework.

Installation

Install via composer:

Upgrading from v1.0.X -> v2.0.X

Please see the release notes here.

Registering the service provider (Laravel users)

For Laravel 5.4 and lower, add the following line to your config/app.php:

For Laravel 5.5 and greater, the package will auto register the provider for you.

Publish the migration and config files

You will need to publish the migration and configuration file before you can begin using the package. To do so run the following in your console:

`

Next, you need to run the migration for the new database table. Run the following in your console:

`

Setting up the middleware (important!)

In order to begin logging requests and responses you will have to attach the middleware to the routes you want to log. The package does not make this assumption for you, since not everyone may want to log every route.

Now, navigate to your /app/Http/Kernel.php

You can choose which method you would like to use. We've provided a few different options below:

OPTION 1: Bind the middleware to a name you can call only on the routes you want

Then apply the named middleware to whatever routes you want:

OPTION 2: Assign the middleware to a route group

OPTION 3: Assign the middleware to every route

That's it! The middleware will log every incoming request it receives!

Customizing your configuration (optional)

This package provides a few customizations you can make.

When you navigation to app/config you will see a log-requests-and-responses.php file. It will contain the following:

Housekeeping

You may want to utilize some housekeeping to prevent your logs table from getting too large. This package supplies a preregistered command for wiping the table clean. You may run it manually

`

You may also schedule it to be run automatically in app/Console/Kernel.php:

Advanced Usage

Conditional logging

This package provides support for specifying custom conditions before a request/response is logged to the database.

It comes with 3 default options out of the box:

Creating your own conditional logic is pretty straightforward and can be done in 2 simple steps:

  1. First, create a custom class that will perform your conditional checks for logging. For demonstration purposes let's say we're going to create a conditional logic check to only log requests made from external services and not your own web app. You can use the following code as a template.

  2. Open up your config/log-requests-and-responses.php and set the should_log_handler key to your class.

...and that's it! Your custom logging logic will now be used any time the middleware is executed.

Model scopes

If you would like to work with the data you've logged, you may want to retrieve data based on the http code your app returned for that request.

Replacing the RequestResponseLog model with your own

You may want to extend the base RequestResponseLog model with your own. This is entirely possible.

First, create your own model

`

Then in your model, extend the base model:

Then in your app/config/log-requests-and-responses.php:

Now the package will utilize your model instead of the default one.

Testing

You can run the tests with:

License

The MIT License (MIT). Please see License File for more information.


All versions of laravel-request-response-logger with dependencies

PHP Build Version
Package Version
Requires php Version >=7.0|^8.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 mtownsend/laravel-request-response-logger contains the following files

Loading the files please wait ....