Download the PHP package ernestoch/user-auditable-for-laravel without Composer

On this page you can find all versions of the php package ernestoch/user-auditable-for-laravel. 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 user-auditable-for-laravel

User Auditable for Laravel

PHP Version Laravel Version Latest Version on Packagist Tests Total Downloads

A Laravel package that provides user auditing capabilities for your database tables and Eloquent models. Easily track which users create, update, and delete records in your application.

Features

Requirements

Laravel 9 notice: Laravel 9 reached End of Life in February 2024 and carries known security advisories. This package declares compatibility with Laravel 9 but CI tests for that version may fail due to Composer blocking EOL packages. Use Laravel 9 at your own risk.

Installation

Configuration

Publish the configuration file (optional):

Note: fullAuditable() requires user_auditable to also be listed in enabled_macros. If you disable user_auditable in the published config, registering full_auditable will throw a RuntimeException at boot time.

Usage

Migrations

Use the provided macros in your migrations:

Custom Event Columns

Use eventAuditable() to stamp any custom business event with its own _at timestamp and/or _by user FK, reading user_table and key_type from config('user-auditable.defaults'):

Reversing Migrations

All creation macros have corresponding drop macros for clean rollbacks:

Models

Use the UserAuditable trait in your Eloquent models:

Use the EventAuditable trait for dynamic access to custom events:

Relationships

The traits automatically provide relationships:

UserAuditable Relationships

EventAuditable Relationships

With EventAuditable trait, access relationships dynamically for any event:

Query Scopes

UserAuditable Scopes

Filter records by user actions:

EventAuditable Scopes

With EventAuditable trait, filter by any event user dynamically:

Change Tracking

ChangeAuditable automatically logs every create, update, delete, restore, and revert operation on your model to a dedicated audit_logs table.

Migration

Create the audit log table using the provided macro:

Model Setup

$hidden model properties are also automatically excluded from audit logs.

Accessing Audit Logs

Reverting to a Previous State

revertTo() behavior:

updated, deleted, and reverted logs are typically revertible (they include old_values).
created and restored logs are typically not revertible because they do not include old_values.

Diffing Between Two Logs

Pruning Old Logs

Configuration

Available Macros

Macro Description Parameters
userAuditable() Adds user auditing columns ?string $userTable = null, ?string $keyType = null
dropUserAuditable() Removes user auditing columns bool $dropForeign = true
fullAuditable() Adds timestamps, soft deletes, and user auditing ?string $userTable = null, ?string $keyType = null
dropFullAuditable() Removes timestamps, soft deletes, and user auditing bool $dropForeign = true
uuidColumn() Adds UUID column string $columnName = 'uuid'
dropUuidColumn() Removes UUID column string $columnName = 'uuid'
ulidColumn() Adds ULID column string $columnName = 'ulid'
dropUlidColumn() Removes ULID column string $columnName = 'ulid'
statusColumn() Adds status enum column string $columnName = 'status', array $allowed = ['active','inactive','pending'], string $default = 'active'
dropStatusColumn() Removes status column string $columnName = 'status'
eventAuditable() Adds a custom event timestamp and/or user FK string $event, ?string $column = null
dropEventAuditable() Removes custom event columns string $event, ?string $column = null, bool $dropForeign = true
auditLogTable() Creates the standard audit log table structure no parameters
dropAuditLogTable() Drops the current audit log table no parameters

Testing

Setup

A .env.testing.example file is included in the repository as a reference. Copy it and fill in your local values:

โš ๏ธ Never commit .env.testing to the repository. It is already listed in .gitignore.

Running with MySQL

Set the following environment variables and fill in your values in the .env.testing file:

Then set DB_CONNECTION in your terminal session:

Running with SQLite (default)

No additional configuration is needed. SQLite in-memory is the default driver used by phpunit.xml.

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

Author: Ernesto Chapon.

All contributors (โš ๏ธ Not available yet).

License

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


All versions of user-auditable-for-laravel with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
laravel/framework Version >=9.0 <14.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 ernestoch/user-auditable-for-laravel contains the following files

Loading the files please wait ...