Download the PHP package prahsys/laravel-api-logs without Composer

On this page you can find all versions of the php package prahsys/laravel-api-logs. 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-api-logs

Prahsys Laravel API Logs

A comprehensive Laravel package for logging API requests and responses with idempotency support, model tracking, and configurable data redaction.

Features

Architecture Overview

The package follows a clean event-driven architecture with a lightweight database design:

Design Philosophy

ApiLogItem is designed as a lightweight reference to API requests, not a full data store. This approach:

The actual request/response data is processed through configurable log channels where it can be:

Key Components

  1. ApiLogMiddleware: Captures request/response data and manages correlation IDs
  2. CompleteApiLogItemEvent: Dispatched after request completion
  3. CompleteApiLogItemListener: Processes model associations and log data
  4. ApiLogPipelineManager: Registers Monolog processors for automatic redaction
  5. ApiLogProcessor: Monolog processor that applies redaction pipelines to log records
  6. ApiLogItemTracker: Tracks models during request processing
  7. Redaction System: Pipeline-based data redaction with configurable redactors

Installation

Configuration

1. Publish Configuration and Migrations

2. Environment Configuration

3. Logging Channels

Add to your config/logging.php:

4. Middleware Registration

Add to your app/Http/Kernel.php:

Usage

Basic Usage

Once configured, the package automatically logs API requests. Include an Idempotency-Key header for request correlation:

Outbound API Logging with Guzzle

The package includes Guzzle middleware to log outbound HTTP requests your application makes to external APIs.

Basic Setup

Add the middleware to your Guzzle client's handler stack:

Adding to Existing Handler Stack

If you already have a handler stack with other middleware:

Skip Logging for Specific Requests

Configuration

Configure outbound logging in your environment:

Or in config/api-logs.php:

Model Tracking

Add the HasApiLogItems trait to models you want to track:

Models created or updated during API requests are automatically associated with the API log item. This is particularly useful for:

Accessing Tracked Data

Configuration Options

Channel Configuration

Configure different redaction pipelines for different channels in config/api-logs.php. Each channel can have its own redaction strategy based on the destination's requirements:

Available Redactors

Wildcard Pattern Support

The DotNotationRedactor supports powerful wildcard patterns:

Examples:

Extending ApiLogItem for Custom Data Storage

The default ApiLogItem stores lightweight references. You can extend it to store additional data:

Alternative approaches:

Creating Custom Redactors

The easiest way to create custom redactors is by extending DotNotationRedactor, just like the built-in CommonHeaderFieldsRedactor and CommonBodyFieldsRedactor:

Example: PCI DSS Redactor

Example: Healthcare (HIPAA) Redactor

Example: General PII Redactor

Advanced: Custom Replacement Logic

You can also provide custom replacement logic using closures:

Using Custom Redactors

Once created, use your custom redactors in your channel configuration:

Event System

Listening to Events

You can listen to CompleteApiLogItemEvent to add custom processing:

Event Data

The event contains:

Compliance Features

This package provides features that are generally useful for compliance requirements:

PCI DSS Support

SOC 2 Support

External Service Integration

Monitoring and Alerting Services

The package integrates seamlessly with external monitoring services:

Sentry Integration:

Axiom Integration:

Other Services:

Database Pruning and Log Management

Database Pruning

ApiLogItems are designed for long-term retention (365 days by default) but can be pruned using Laravel's built-in model pruning:

Configure retention in your environment:

Log File Management

Separate from database retention, configure log rotation per channel:

Best practices:

Performance Considerations

Testing

Run the test suite:

Compliance Configuration Examples

PCI DSS Configuration

For environments handling payment card data, configure appropriate redaction and retention:

SOC 2 Configuration

For SOC 2 environments, configure comprehensive logging with security controls:

Data Retention Policies

Configure retention policies based on your compliance requirements:

Security Notes

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests for new functionality
  5. Submit a pull request

License

This package is open-sourced software licensed under the MIT license.

Support

For support, please open an issue on the GitHub repository or contact the maintainers.


All versions of laravel-api-logs with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
illuminate/support Version ^10.0|^11.0|^12.0
illuminate/database Version ^10.0|^11.0|^12.0
illuminate/http Version ^10.0|^11.0|^12.0
illuminate/queue Version ^10.0|^11.0|^12.0
spatie/laravel-data Version ^3.0|^4.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 prahsys/laravel-api-logs contains the following files

Loading the files please wait ....