Top Related Projects
Log activity inside your Laravel app
List of 126 languages for Laravel Framework, Laravel Jetstream, Laravel Fortify, Laravel Breeze, Laravel Cashier, Laravel Nova, Laravel Spark and Laravel UI.
:dromedary_camel: Laravel log viewer
A MongoDB based Eloquent model and Query builder for Laravel (Moloquent)
Debugbar for Laravel (Integrates PHP Debug Bar)
Quick Overview
Laravel Auditing is a package for Laravel that allows you to keep a history of model changes in your application. It provides an easy way to implement auditing functionality, tracking who made changes, what changes were made, and when they occurred.
Pros
- Easy integration with Laravel models
- Customizable audit output
- Supports multiple audit drivers (database, file, etc.)
- Provides a clean and intuitive API for retrieving audit history
Cons
- Can potentially increase database size significantly if used extensively
- May impact performance on high-traffic applications if not optimized
- Limited built-in support for complex data structures
- Requires manual configuration for each model to be audited
Code Examples
- Implementing auditing on a model:
use OwenIt\Auditing\Contracts\Auditable;
use OwenIt\Auditing\Auditable as AuditableTrait;
class User extends Model implements Auditable
{
use AuditableTrait;
// Model implementation
}
- Retrieving audit history for a model:
$user = User::find(1);
$audits = $user->audits;
foreach ($audits as $audit) {
echo $audit->event . ' by ' . $audit->user->name . ' on ' . $audit->created_at;
}
- Customizing audit output:
class User extends Model implements Auditable
{
use AuditableTrait;
public function transformAudit(array $data): array
{
$data['custom_field'] = 'Custom value';
return $data;
}
}
Getting Started
-
Install the package via Composer:
composer require owen-it/laravel-auditing
-
Publish the configuration file:
php artisan vendor:publish --provider "OwenIt\Auditing\AuditingServiceProvider" --tag="config"
-
Run migrations to create the audits table:
php artisan migrate
-
Implement the
Auditable
contract and use theAuditableTrait
in your model:use OwenIt\Auditing\Contracts\Auditable; use OwenIt\Auditing\Auditable as AuditableTrait; class User extends Model implements Auditable { use AuditableTrait; }
-
Configure audit settings in your model (optional):
protected $auditInclude = ['name', 'email']; protected $auditTimestamps = true;
Competitor Comparisons
Log activity inside your Laravel app
Pros of laravel-activitylog
- More flexible logging options, including custom activity models and log names
- Built-in support for cleaning old records
- Extensive documentation and examples
Cons of laravel-activitylog
- Slightly more complex setup process
- May require more configuration for basic auditing tasks
Code Comparison
laravel-activitylog:
activity()
->performedOn($anEloquentModel)
->causedBy($user)
->withProperties(['custom' => 'properties'])
->log('Look, I logged something');
laravel-auditing:
$model->update($attributes);
// Auditing is automatically handled
Both packages provide powerful auditing capabilities for Laravel applications, but they differ in their approach and feature set. laravel-activitylog offers more flexibility and customization options, making it suitable for complex logging requirements. It allows for detailed activity tracking beyond simple model changes.
On the other hand, laravel-auditing focuses on seamless integration with Eloquent models, providing automatic auditing with minimal setup. It's more straightforward for basic auditing needs but may require additional work for more advanced scenarios.
The choice between these packages depends on the specific requirements of your project, such as the level of detail needed in logs, the complexity of your auditing needs, and the desired balance between ease of use and flexibility.
List of 126 languages for Laravel Framework, Laravel Jetstream, Laravel Fortify, Laravel Breeze, Laravel Cashier, Laravel Nova, Laravel Spark and Laravel UI.
Pros of lang
- Focuses specifically on language translations for Laravel applications
- Extensive collection of language files for numerous locales
- Regular updates and contributions from the community
Cons of lang
- Limited to language translations, not a full auditing solution
- Requires manual integration and management of language files
- May not cover all custom text or dynamic content in an application
Code Comparison
lang:
// resources/lang/en/validation.php
return [
'accepted' => 'The :attribute must be accepted.',
'active_url' => 'The :attribute is not a valid URL.',
'after' => 'The :attribute must be a date after :date.',
];
laravel-auditing:
// app/Models/User.php
use OwenIt\Auditing\Contracts\Auditable;
class User extends Model implements Auditable
{
use \OwenIt\Auditing\Auditable;
}
Summary
While lang provides comprehensive language translations for Laravel applications, laravel-auditing offers a broader auditing solution for tracking model changes. lang is ideal for internationalization, but lacks the extensive tracking and auditing features of laravel-auditing. The choice between these repositories depends on whether the primary need is for language localization or comprehensive model auditing in a Laravel application.
:dromedary_camel: Laravel log viewer
Pros of Laravel Log Viewer
- Simple and lightweight solution for viewing Laravel logs
- Easy to install and integrate into existing Laravel projects
- Provides a user-friendly web interface for log viewing
Cons of Laravel Log Viewer
- Limited to viewing logs only, without advanced auditing features
- Lacks customization options for tracking specific events or models
- Does not provide detailed information about user actions or data changes
Code Comparison
Laravel Log Viewer:
Route::get('logs', '\Rap2hpoutre\LaravelLogViewer\LogViewerController@index');
Laravel Auditing:
use OwenIt\Auditing\Contracts\Auditable;
class User extends Model implements Auditable
{
use \OwenIt\Auditing\Auditable;
}
Laravel Log Viewer focuses on displaying log files through a simple route, while Laravel Auditing requires model implementation for detailed event tracking.
Laravel Log Viewer is best suited for quick log viewing in development environments, whereas Laravel Auditing offers comprehensive auditing capabilities for production systems that require detailed tracking of data changes and user actions.
A MongoDB based Eloquent model and Query builder for Laravel (Moloquent)
Pros of laravel-mongodb
- Provides seamless integration with MongoDB for Laravel applications
- Supports complex MongoDB queries and aggregations
- Offers MongoDB-specific features like geospatial indexing and GridFS
Cons of laravel-mongodb
- Limited to MongoDB database, while laravel-auditing works with multiple database types
- Requires learning MongoDB syntax and concepts, which may be unfamiliar to SQL developers
- May not have built-in auditing features like laravel-auditing
Code Comparison
laravel-mongodb:
use Jenssegers\Mongodb\Eloquent\Model;
class User extends Model
{
protected $connection = 'mongodb';
}
laravel-auditing:
use OwenIt\Auditing\Contracts\Auditable;
class User extends Model implements Auditable
{
use \OwenIt\Auditing\Auditable;
}
Summary
laravel-mongodb is specifically designed for integrating MongoDB with Laravel, offering powerful MongoDB-specific features. It's ideal for projects that require MongoDB's flexibility and scalability. However, it's limited to MongoDB and may require additional effort for auditing.
laravel-auditing, on the other hand, focuses on providing auditing capabilities for Laravel models across various database types. It's more versatile in terms of database support but doesn't offer MongoDB-specific features.
The choice between these repositories depends on the project's specific database requirements and the need for built-in auditing functionality.
Debugbar for Laravel (Integrates PHP Debug Bar)
Pros of Laravel Debugbar
- Provides real-time debugging information in a convenient toolbar
- Offers extensive performance profiling and query analysis
- Integrates seamlessly with Laravel's built-in debugging tools
Cons of Laravel Debugbar
- Can impact application performance when enabled in production
- May expose sensitive information if not properly configured
- Requires manual setup and configuration for optimal use
Code Comparison
Laravel Debugbar:
use Barryvdh\Debugbar\Facade as Debugbar;
Debugbar::info('Info message');
Debugbar::error('Error message');
Debugbar::warning('Warning message');
Laravel Auditing:
use OwenIt\Auditing\Models\Audit;
$audits = $model->audits;
$audit = Audit::find(1);
$audit->getMetadata();
Laravel Debugbar focuses on real-time debugging and performance analysis, providing a visual toolbar for developers. It's particularly useful during development and testing phases.
Laravel Auditing, on the other hand, is designed for tracking and logging changes to Eloquent models. It's more suited for maintaining an audit trail of data modifications in production environments.
While both packages enhance Laravel development, they serve different purposes. Laravel Debugbar is a debugging tool, whereas Laravel Auditing is a data integrity and tracking solution.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
This package will help you understand changes in your Eloquent models, by providing information about possible discrepancies and anomalies that could indicate business concerns or suspect activities.
Laravel Auditing allows you to keep a history of model changes by simply using a trait. Retrieving the audited data is straightforward, making it possible to display it in various ways.
Official Documentation
For more information on how to use the package, please refer to our official documentation available on laravel-auditing.com or in the repository documentation file. Our documentation provides detailed instructions on how to install and use the package, as well as examples and best practices for auditing in Laravel applications.
Thank you for choosing OwenIt\LaravelAuditing!
Version Information
Version | Illuminate | Status | PHP Version |
---|---|---|---|
13.x | 7.x.x - 11.x.x | Active support :rocket: | > = 7.3 | 8.0 |
12.x | 6.x.x - 9.x.x | End of life | > = 7.3 | 8.0 |
11.x | 5.8.x - 8.x.x | End of life | > = 7.3 |
10.x | 5.8.x - 7.x.x | End of life | > = 7.2.5 |
9.x | 5.8.x - 6.x.x | End of life | > = 7.1.3 |
8.x | 5.2.x - 5.7.x | End of life | > = 7.0.13 |
7.x | 5.2.x - 5.6.x | End of life | > = 7.0.13 |
6.x | 5.2.x - 5.6.x | End of life | > = 7.0.13 |
5.x | 5.2.x - 5.5.x | End of life | > = 7.0.13 |
4.x | 5.2.x - 5.5.x | End of life | > = 5.5.9 |
3.x | 5.2.x - 5.4.x | End of life | > = 5.5.9 |
2.x | 5.1.x - 5.3.x | End of life | > = 5.5.9 |
Contributing
Please see the contributing entry for more details.
Credits
Special thanks for keeping this project active.
License
The Laravel Auditing package is open source software licensed under the MIT LICENSE.
Top Related Projects
Log activity inside your Laravel app
List of 126 languages for Laravel Framework, Laravel Jetstream, Laravel Fortify, Laravel Breeze, Laravel Cashier, Laravel Nova, Laravel Spark and Laravel UI.
:dromedary_camel: Laravel log viewer
A MongoDB based Eloquent model and Query builder for Laravel (Moloquent)
Debugbar for Laravel (Integrates PHP Debug Bar)
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot