Download the PHP package iamfarhad/laravel-audit-log without Composer

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

Laravel Audit Logger

Latest Version on Packagist Total Downloads PHP Version Laravel Version GitHub stars

License Maintained Tests Code Style PHPStan Scrutinizer Code Quality

Overview

Laravel Audit Logger is a powerful and flexible package designed to provide detailed audit logging for Laravel applications. It enables tracking of all changes to your Eloquent models, ensuring compliance with regulatory requirements, aiding in debugging, and maintaining data integrity. Built with modern PHP and Laravel practices, this package adheres to strict typing, PSR-12 coding standards, and leverages dependency injection for maximum testability and maintainability.

Table of Contents

Features

Requirements

Installation

Install the package via Composer:

After installation, publish the configuration file to customize settings:

This will create a configuration file at config/audit-logger.php where you can adjust settings like the storage driver, table naming conventions, and more.

Configuration

The configuration file config/audit-logger.php allows you to customize the behavior of the audit logger. Below are the key configuration options:

Ensure you review and adjust these settings based on your application's needs, especially for sensitive data exclusion and performance optimization.

Usage

Basic Usage

To make a model auditable, simply add the Auditable trait to your Eloquent model. Ensure strict typing is enabled as per the engineering rules.

Once the trait is added, any changes to the model (create, update, delete, restore) will be automatically logged to a dedicated audit table (e.g., audit_order_logs).

Excluding Fields

To exclude specific fields from being audited, define the $auditExclude property:

Including Specific Fields

Alternatively, you can specify only the fields to audit using $auditInclude:

Advanced Usage

Custom Metadata

You can enrich audit logs with custom metadata by implementing the getAuditMetadata method in your model:

Temporarily Disabling Auditing

For specific operations where auditing is not required, you can disable it temporarily:

Custom Audit Events

To log custom actions beyond standard CRUD operations, dispatch the ModelAudited event manually:

Fluent API for Custom Audit Events

For a more intuitive and readable way to log custom actions, use the fluent API provided by the audit() method:

This fluent interface allows you to chain methods to define the custom action, old and new values, and additional metadata before logging the event. It respects the model's auditable attributes and merges any default metadata defined in getAuditMetadata() with custom metadata provided.

Customizing Audit Logging

If you need to extend the audit logging functionality, you can implement a custom driver by adhering to the AuditDriverInterface. Register your custom driver in a service provider:

Retrieving Audit Logs

Audit logs are accessible via a relationship on the audited model. Use the auditLogs() method to query logs:

For advanced querying, you can directly use the EloquentAuditLog model with various scopes to filter audit logs based on specific criteria:

These scopes allow for flexible and efficient querying of audit logs, making it easier to analyze changes based on action type, date range, or the user responsible for the change.

Performance Optimization

Testing

This package includes a robust test suite. To run the tests locally:

When writing tests for your application, ensure you cover audit logging behavior, especially for critical models. Mock the audit driver if necessary to isolate tests from actual logging.

Security Best Practices

Troubleshooting

Contributing

Contributions are welcome! Please follow the guidelines in CONTRIBUTING.md for submitting pull requests, reporting issues, or suggesting features.

License

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


All versions of laravel-audit-log 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/events Version ^10.0|^11.0|^12.0
illuminate/config Version ^10.0|^11.0|^12.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 iamfarhad/laravel-audit-log contains the following files

Loading the files please wait ....