Download the PHP package hosmelq/laravel-audit-logs without Composer

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

Laravel Audit Logs

Laravel Audit Logs provides a simple, fluent API for recording application audit events. You may include actors, targets, request metadata, and custom metadata for each event.

Table of Contents

Introduction

Audit logs capture meaningful application actions, such as publishing a document, changing account settings, or performing an administrative action. This package provides a clean API to explicitly record those events to a database table with sensible defaults.

Installation

First, install the package via Composer:

Next, publish the configuration and migration files:

If you prefer, you may publish the assets manually:

The installer can run the migrations for you. If you skip that prompt, run them manually:

Configuration

After publishing the package assets, the configuration file will be located at config/audit-log.php. This configuration file allows you to specify default attributes, request metadata capture, retention, and storage.

Default Attributes

You may specify the default bucket and source values using the audit-log.defaults.bucket and audit-log.defaults.source configuration values. These values are used when an audit log is recorded without explicit values.

Request Metadata

HTTP requests may fill missing remoteIp and userAgent values when request capture is enabled. Capture is enabled for remote IP and user agent by default, but console capture is disabled unless audit-log.request.capture_in_console is enabled.

Storage Configuration

Audit logs are written to the configured database table. You may configure the database connection and table name used to store audit logs.

A null storage connection uses Laravel's default database connection.

Environment Variables

The following environment variables are supported:

Recording Audit Logs

The Audit Log Helper

Call the audit_log helper with an event, set the fields you care about, and call record:

Call audit_log() without an event to record prepared logs or run a correlation scope.

Fluent Attributes

Use the fluent builder to attach common audit log attributes:

Optional fields include description, bucket, source, occurredAt, remoteIp, userAgent, id, and correlationId. Tenant, actor, and target IDs may be integers or strings.

You may call toAuditLogData when you need the data object without recording it immediately:

You may also record existing AuditLogData instances through the facade:

Recording Multiple Logs

Pass an iterable to record multiple logs at once:

When an iterable contains more than one log, logs without an explicit correlationId receive the same generated correlation ID.

Correlating Logs

Use correlate when separate record calls should share one correlation ID:

Pass a correlation ID as the second argument when the scope should reuse an existing ID.

Defaults & Missing Values

Missing values follow these rules:

Enum Values

The fluent helper accepts strings or backed enums for events, buckets, sources, actor types, and target types. Backed enum values are stored as strings.

Reading Audit Logs

Use the package model to query stored logs:

JSON columns such as metadata, actor_metadata, and targets are cast to arrays, while occurred_at, inserted_at, and expires_at are cast to immutable dates.

Retention & Pruning

Set audit-log.retention.days to expire audit logs after a fixed number of days. A null value keeps audit logs indefinitely.

When retention is configured, each row receives an expires_at value derived from occurred_at. Prune expired rows using Laravel's model:prune command:

Adding a Custom Audit Log Model

Use a custom model when you need application-specific query scopes or casts. The model must extend the package model:

Register the model once from a service provider:

Testing Your Application

Faking Audit Logs

Call AuditLog::fake() to replace the manager with an in-memory fake:

Assertions

Use fake assertions to verify events by string or backed enum:

Use assertNothingRecorded when no logs should have been recorded:

Inspecting Recorded Logs

Pass a closure to inspect recorded AuditLogData objects:

Retrieve recorded logs as a collection and filter them by event string, backed enum, or closure:

Running the Test Suite

Changelog

See CHANGELOG.md for a list of changes.

Contributing

Pull requests are welcome. Please run the test suite before submitting changes.

License

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


All versions of laravel-audit-logs with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
illuminate/database Version ^12.0 || ^13.0
illuminate/http Version ^12.0 || ^13.0
illuminate/support Version ^12.0 || ^13.0
spatie/laravel-package-tools Version ^1.93
thecodingmachine/safe Version ^3.4
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 hosmelq/laravel-audit-logs contains the following files

Loading the files please wait ...