PHP code example of umanit / trace-user-actions

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

    

umanit / trace-user-actions example snippets




# config/bundles.php
return [
    // ...
    Umanit\TraceUserActions\UmanitTraceUserActionsBundle::class => ['all' => true],
];

function deleteProductAction(Product $product, EventDispatcherInterface $eventDispatcher): Response
{
    // [...]
    $eventDispatcher->dispatch(new UserActionEvent(sprintf('Delete product "%s"', $product->getName()), $this->getUser()));
    // [...]
}

[2022-07-13T09:19:23.886319+02:00] umanit_trace_user_actions.INFO: User login {"user":"[email protected]"} []
[2022-07-13T09:19:41.715806+02:00] umanit_trace_user_actions.INFO: User logout {"user":"[email protected]"} []

[2022-07-13T10:15:27.962118+02:00] umanit_trace_user_actions.INFO: Delete product "Example product" {"user":"[email protected]"} []