1. Go to this page and download the library: Download popphp/pop-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/ */
popphp / pop-audit example snippets
use Pop\Audit\Auditor;
use Pop\Audit\Adapter\File;
$auditor = new Auditor(new File(__DIR__ . '/tmp')); // Folder passed to the File adapter
$auditor->setModel('MyApp\Model\User', 1001); // Model name and model ID (
use Pop\Http\Client;
use Pop\Http\Auth;
use Pop\Audit\Auditor;
use Pop\Audit\Adapter\Http;
$old = [
"id" => 1,
'username' => 'admin',
'email' => '[email protected]'
];
$new = [
"id" => 1,
'username' => 'admin2',
'email' => '[email protected]'
];
$sendClient = new Client(
'http://audit.localhost',
Auth::createBearer('AUTH_TOKEN'),
['method' => 'POST']
);
$auditor = new Auditor(new Http($sendClient));
$auditor->setModel('MyApp\Model\User', 1001);
$auditor->setUser('testuser', 101);
$auditor->setDomain('users.localhost');
$response = $auditor->send($old, $new);
$fetchClient = new Client(
'http://audit.localhost',
Auth::createBearer('AUTH_TOKEN'),
['method' => 'GET']
);
$auditor = new Auditor(new Http($sendClient, $fetchClient));
use Pop\Audit\Auditor;
use Pop\Audit\Adapter\File;
use Pop\Audit\Model\AuditableModel;
class User extends AuditableModel
{
// ...
}
$user = new User();
$user->setAuditor(new Auditor(new File(__DIR__ . '/tmp')));
if ($user->isAuditable()) {
$user->getAuditor()->setModel('MyApp\Model\User', 1001);
$user->getAuditor()->send($old, $new); // $old/$new as shown under Storing Changes
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.