Ordit Kohana ORM Audit: Track calls to Kohana framework ORM classes

Recommend this page to a friend!
  Info   Screenshots   View files (21)   Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 138 All time: 8,969 This week: 317
Version Licenses PHP version Categories
kohana-orm-audit 1.0Artistic License, F...5.3PHP 5, Databases, Logging, Design Pat...
Description Author

This package can track calls to Kohana framework ORM classes.

It provides a class that extends Kohana ORM base class to track calls to CRUD functions and log details about each call in a database.

The package also provides class to view the log CRUD function calls in a Web page.

Innovation Award
PHP Programming Innovation award nominee
July 2013
Number 10
Kohana is a PHP framework that provides Object-Relational Mapping (ORM) classes. Applications may use those classes to store and retrieve information from a database and access it using objects of the classes.

When you want to debug a database application, it is useful to see what types of databases accesses the application is doing in the context of the objects that the application uses.

This package can provide means to log accesses to Kohana framework ORM classes in a way that it is useful to help debugging the application.

Manuel Lemos
Picture of Stefan Jibrail Froelich
  Performance   Level  
Name: Stefan Jibrail Froelich is available for providing paid consulting. Contact Stefan Jibrail Froelich .
Classes: 6 packages by
Country: Ghana Ghana
Age: ???
All time rank: 11032 in Ghana Ghana
Week rank: 246 2 in Ghana Ghana
Innovation award
Innovation award
Nominee: 3x

# Ordit

Ordit is a Kohana 3.x module that adds automatic auditing to the Official ORM module.

Ordit is a transparent extension that audits all CUD actions on your objects.
It includes  a Log Viewer to view all Audit logs.

## Getting started

Before we use Ordit, we must enable the modules required

		'database' => MODPATH.'database',
		'orm' => MODPATH.'orm',
		'ordit' => MODPATH.'ordit',

[!!] Ordit requires the ORM module (plus its dependencies) to work.

### Setting up the database

You need to create a table in your database to hold all your logs.

A script is included in the module named `ordit_logs.sql`
The script is for a mysql database running the InnoDB engine.

The table is configured as follows:

	Table Name :: 
	Columns ::
		`model` CHAR(50) NOT NULL,
		`action` CHAR(7) NOT NULL,
		`values` TEXT NOT NULL,
		`user` CHAR(50) NOT NULL,
### Overriding the Ordit::get_username Method

In order to provide the current logged in user's username for auditing,
create a class in your classes folder named `Ordit` that extends the `Model_Ordit` class. 
Then override the `get_username` method to return the current logged in user's username. The example below uses
the default `Auth` module.

	class Ordit extends Model_Ordit
		protected function get_username()
			return Auth::instance()->get_user()->username;

### Auditing Your Models

To enable auditing of your ORM models, you simple extend `Ordit`.

	class Model_Model extends Ordit

Any CREATE, UPDATE and DELETE actions are automatically and transparently logged.
You don't have to do anything else.

### Viewing Your Logs
The module includes a log viewer. 

You can view logs at (http://site_root/ordit)

[!!]The log viewer was modified from [Kohana Log Viewer](https://github.com/ajaxray/Kohana-Log-Viewer) viewer.


### Log Changes to Related Modules
Currently, changes to related modules are logged as an empty array.

##Improve Viewer

Add pagination to the log results

Add ability to search by currently `undefined parameters`
  • Log-Viewer.png
File Role Description
assets (3 files)
classes (1 file, 2 directories)
config (1 file)
guide (1 directory)
views (1 directory)
init.php Example Class source
ordit_logs.sql Data Auxiliary data
readme.md Data Auxiliary data

  Files  /  assets  
File Role Description
   bootstrap.min.css Data Auxiliary data
   jquery.js Data Auxiliary data
   style.css Data Auxiliary data

  Files  /  classes  
File Role Description
Controller (1 file)
Model (1 file, 1 directory)
   Ordit.php Class Class source

  Files  /  classes  /  Controller  
File Role Description
   Ordit.php Class Class source

  Files  /  classes  /  Model  
File Role Description
Ordit (2 files)
   Ordit.php Class Class source

  Files  /  classes  /  Model  /  Ordit  
File Role Description
   Log.php Class Class source
   Ordit.php Class Class source

  Files  /  config  
File Role Description
   userguide.php Conf. Configuration script

  Files  /  guide  
File Role Description
ordit (5 files)

  Files  /  guide  /  ordit  
File Role Description
   index.md Doc. Documentation
   installation.md Doc. Documentation
   menu.md Doc. Documentation
   todo.md Doc. Documentation
   usage.md Doc. Documentation

  Files  /  views  
File Role Description
ordit (4 files)

  Files  /  views  /  ordit  
File Role Description
   daylist.php Output Sample output
   layout.php Output Sample output
   monthlist.php Output Sample output
   report.php Output Sample output

 Version Control Unique User Downloads Download Rankings  
This week:0
All time:8,969
This week:317

For more information send a message to info at phpclasses dot org.