Download the PHP package aw3r1se/laravel-audit-core without Composer

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

laravel-audit-core

Eloquent model and relation change auditing for Laravel, with a pluggable delivery transport. Records create/update/delete state plus relation mutations (attach/detach/sync/toggle/associate/pivot updates) into a request-scoped buffer, then dispatches a single event per request.

It is Octane/RoadRunner safe: the buffer is a scoped singleton and is always resolved inside the recording closures, never captured at model boot.

What this package does not do

It does not talk to any storage or message broker, and it has no read API. The buffer is handed to a transport you provide. The read side (querying past audit logs, presentation, localization) stays in your application — this package is purely the recording engine.

Install

The service provider is auto-discovered.

Usage

1. Make a model auditable

$auditIgnoredFields is merged with the global config('audit.ignored_fields'), so you only list the extras. For computed values, override getAuditIgnoredFields() / getAuditIgnoredRelations() instead.

The trait overrides the Eloquent relation factory methods, so relation changes on belongsTo, hasOne/Many, morphOne/Many, belongsToMany and morphToMany are audited automatically. No changes to your relation definitions are needed.

Weak entities (no primary key)

Some child records have no key of their own ($incrementing = false, no surrogate id). For those, getKey() is null, so a recorded id would be meaningless. The engine detects this and falls back to a filtered attribute snapshot of the row (honouring getHidden() and the ignored fields), both in the relation payload (attached/detached) and in a model's own model_id. You get the actual state of the change instead of null.

Recording strategy: diff vs snapshot

By default each model event is recorded as a diff — new attributes on create, changed attributes on update, the original row on delete. You can instead record a snapshot: the model's full filtered attributes plus a recursive snapshot of selected relations.

Pick the default for every model in config, and override it per model:

A snapshot entry's state looks like:

Relations are queried fresh at capture time (honouring getHidden() and the ignored fields, same as attributes), so the snapshot reflects current persisted state. Deletions are captured on deleting, while relations are still attached.

This only shapes a model's own create/update/delete entry; relation-mutation recording (attach/detach/sync) is independent and runs under either strategy. To add your own strategy, implement Aw3r1se\Audit\Contracts\AuditStrategy and register it under config('audit.strategies') (or reference it by class-string).

2. Attach the middleware

Add Aw3r1se\Audit\Http\Middleware\AuditActions to the route group you want audited (typically your API). It records every POST/PUT/PATCH/DELETE and dispatches Aw3r1se\Audit\Events\UserActionEvent carrying an immutable AuditEvent. Pass route arguments to exclude request keys from the captured body, e.g. ->middleware(AuditActions::class.':password').

3. Provide a transport

Implement Aw3r1se\Audit\Contracts\AuditTransport and point config at it:

The package ships NullTransport (default, no-op) and LogTransport (PSR-3). Delivery runs through the queued ForwardAuditToTransport listener, so it never blocks the request — configure your queue accordingly.

Configuration

key default purpose
strategy 'changes' default recording strategy (changes / snapshot)
strategies changes/snapshot map key → AuditStrategy class, for per-model selection
transport NullTransport::class who receives each AuditEvent
user_id_attribute audit_user_id request attribute used to resolve a logged-out actor
auditable_methods ['POST','PUT','PATCH','DELETE'] HTTP methods that trigger an audit
ignored_fields ['created_at','updated_at'] attributes stripped from every recorded state

Testing


All versions of laravel-audit-core with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
illuminate/contracts Version ^11.0|^12.0
illuminate/database Version ^11.0|^12.0
illuminate/http Version ^11.0|^12.0
illuminate/support Version ^11.0|^12.0
psr/log Version ^3.0
symfony/http-foundation Version ^7.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 aw3r1se/laravel-audit-core contains the following files

Loading the files please wait ...