1. Go to this page and download the library: Download glueful/audit library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
glueful / audit example snippets
use Glueful\Events\Contracts\BaseEvent;
use Glueful\Extensions\Audit\Contracts\{AuditableEvent, AuditableEventDefaults};
final class EntryPublished extends BaseEvent implements AuditableEvent
{
use AuditableEventDefaults; // defaults for target/changes/metadata — override as needed
public function __construct(
public readonly string $entryUuid,
public readonly string $title,
) {
parent::__construct();
}
public function auditAction(): string { return 'published'; }
public function auditCategory(): string { return 'content'; }
public function auditTarget(): array
{
return ['type' => 'content_entry', 'uuid' => $this->entryUuid, 'label' => $this->title];
}
}
// Anywhere you already dispatch events:
$this->events->dispatch(new EntryPublished($uuid, $title));