PHP code example of polaris / audit

1. Go to this page and download the library: Download polaris/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/ */

    

polaris / audit example snippets


use Polaris\Audit\AuditPlugin;

$polaris = Polaris::create(new Config(
    ...,
    plugins: [new AuditPlugin(
        retention: ['default' => 'P90D', 'names' => ['user.deleted' => 'P7Y']],
        hashChain: false,                       // true links each row to the previous by SHA-256
        sinks: [new FileSink('var/audit.jsonl')], // beside the database: Psr3Sink, FileSink, WebhookSink, yours
        names: ['billing.invoice_paid' => 'An invoice was paid'],   // your own event names
        httpClient: $psr18, requestFactory: $psr17, streamFactory: $psr17,   // enables the organizations' drains
    )],
));