For a Web-Application with many Database
related events I want to build a Changelog
. That should log what users have done, so its a Userlog too.
The App is huge, has a complex role based user access system and there will be hundreds of different events (changes) that may occur.
This all should be Database-Driven
, in PHP
and needs at least a View
to search the Logs
.
But in short, I have totally no idea how to design that all and need some tips or inspirations, maybe what others have done.
I've done this in the past and found basically 2 approaches: Model-based and Controller-based.
Model-based within the model itself override the
save
andupdate
methods (assuming an ActiveRecord pattern) to create a new entry in theChangeLog
table.Controller-based add the
ChangeLog
record creation logic to each controller that you want to track.I prefer the Controller-based approach since you have more control over what's going on and when. Also, you have full access to the user session so it's easier to add tracking for auditing purposes.