Download the PHP package arpanihan/auditify without Composer
On this page you can find all versions of the php package arpanihan/auditify. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download arpanihan/auditify
More information about arpanihan/auditify
Files in arpanihan/auditify
Package auditify
Short Description A high-performance, decoupled audit logging and real-time threat detection package for Laravel. Features action log diffs, session activity tracking, custom authorization callbacks, and queued alerts.
License MIT
Informations about the package auditify
Auditify β High-Performance, Decoupled Audit Logging for Laravel
Auditify is an easy-to-use, high-performance audit logging and threat detection package for Laravel.
π Official Landing Page & Demo: arpa12.github.io/laravel-auditify-landingPage
Unlike standard logging libraries, Auditify uses a decoupled database design to separate logs into three distinct tables. This optimizes database table indexing, reduces write congestion, and guarantees clean scale organization as your application grows.
Table of Contents
- Requirements
- Features
- Dashboard
- Reports & Analytics Module
- Decoupled Log Modules
- Real-Time Threat Engine
- XSS Attack Shield
- Frontend Event Logging API
- Admin-Only Access & Custom Authorization Gate
- Installation
- Configuration
- Manual Logging & Helper Methods
- Artisan Commands
- Routes Reference
- Testing
- Author
- License
π₯οΈ Requirements
| Laravel | PHP |
|---|---|
| 13.x | 8.3 β 8.4 |
| 11.x, 12.x | 8.2 β 8.4 |
| 10.x | 8.2 β 8.3 |
π Features
π Dashboard
URL: /auditify
The main glassmorphic dashboard aggregates action logs, page visits, and threat alerts into an interactive screen:
- Metrics counters β total action logs, activity logs, and security logs with unread indicators.
- Log summaries β breakdowns of operations (Create, Update, Delete) and authentication events (Login, Logout).
- 7-day trend graph β comparative daily counts of Actions vs Activities plotted on Chart.js.
- Top active users & top modified modules β lists of most active user IDs and frequently changed models.
- Live recent logs β lists of the most recent visitor actions and security alerts.
π Reports & Analytics Module
URL: /auditify/reports
A comprehensive reporting panel offering detailed statistical breakdowns over custom timeframes (Last 7 Days, Last 30 Days, or Last 90 Days) featuring interactive Chart.js charts:
- Overview Analytics: System log activity trends mapped using multi-line charts.
- Action Reports: Actions by type (Doughnut Chart) and most changed models (Horizontal Bar Chart), coupled with a detailed database modifications table and CSV/Excel/PDF download options.
- Activity Reports: Top visited pages/URLs (Horizontal Bar Chart) and peak activity hours (Bar Chart), coupled with a detailed activity table and CSV/Excel/PDF download options.
- Security Reports: Alerts by severity (Doughnut Chart), top threat origin IPs (Bar Chart), and resolution status distribution (Pie Chart), coupled with a detailed security incident table and CSV/Excel/PDF download options.
- Format Exports: Support for exporting timeframe-filtered reports in CSV, Excel (xlsx), and clean printable PDF formats.
ποΈ Decoupled Log Modules
Auditify separates data logging into three target models under Auditify\Models to avoid write bottlenecks. Here is the exact database schema and attributes captured for each log type:
Action Logs (ActionLog)
- Table Name:
audit_action_logs - Purpose: Tracks Eloquent database modifications (inserts, updates, deletes, and restores).
- Captured Attributes / Database Columns:
id(BigInt, Primary Key)user_id&user_type(Nullable Morphs) β Polymorphic relationship to the user making the database modification.subject_id&subject_type(Nullable Morphs) β Polymorphic relationship to the actual model being modified.action(String) β The query event (created,updated,deleted,restored).module(String) β Name of the affected model module/class (e.g.,Post,User,Role).description(Text, Nullable) β Friendly readable log summary description.old_values(JSON, Nullable) β Casted array of model attribute values before the operation.new_values(JSON, Nullable) β Casted array of model attribute values after the operation.ip_address(String, Nullable) β IP address of the client triggering the event.url(Text, Nullable) β HTTP Request URL where the change originated.user_agent(Text, Nullable) β HTTP User-Agent string.created_at&updated_at(Timestamps)
Activity Logs (ActivityLog)
- Table Name:
audit_activity_logs - Purpose: Logs visitor requests, navigation, custom application actions, and auth flows. Features a dedicated detail page view (
GET /activity-logs/{id}) to inspect logged metadata. - Captured Attributes / Database Columns:
id(BigInt, Primary Key)user_id&user_type(Nullable Morphs) β Polymorphic relationship to the visitor (if authenticated).activity(String) β The type of operation/activity (e.g.,Page Visit,Login,Logout,Failed Login, or custom events).properties(JSON, Nullable) β Casted array storing context metadata or custom event payloads.url(Text, Nullable) β Request URL path.ip_address(String, Nullable) β Visitor IP address.user_agent(Text, Nullable) β Visitor User-Agent string.created_at&updated_at(Timestamps)
Security Logs (SecurityLog)
- Table Name:
audit_security_logs - Purpose: Logs alerts generated by the XSS protection middleware, rate limits, or automated threat rules.
- Captured Attributes / Database Columns:
id(BigInt, Primary Key)user_id&user_type(Nullable Morphs) β Polymorphic relationship to the user (if authenticated).severity(String) β Alert priority (low,medium,high,critical).title(String) β Brief name of the incident (e.g.,XSS Attack Blocked,Failed Logins Peak).description(Text, Nullable) β In-depth details regarding why the threat was flagged.is_read(Boolean) β Read/unread toggle flag for admin dashboard alerts.status(String) β Alert resolution state (pendingorresolved).resolved_at(DateTime, Nullable) β Timestamp when the incident was marked resolved/read.resolution_notes(Text, Nullable) β Text explaining the resolution strategy.method(String, Nullable) β Request HTTP method (GET,POST, etc.).route_name(String, Nullable) β Named route where the attack/alert occurred.payload(JSON, Nullable) β Casted request body payload parameters scanned by the security shield.ip_address(String, Nullable) β Origin IP address of the incident.user_agent(Text, Nullable) β Incident Client User-Agent.created_at&updated_at(Timestamps)
π Real-Time Threat Engine
Auditify automatically monitors activity logs and logs high-priority Security entries when rules are broken:
- Mass Delete Shield: Fires a
criticalsecurity log if a user deletes 5 or more records (default) in a single model within 5 minutes. - Bulk Update Shield: Fires a
highsecurity log if a user updates 10 or more records (default) in a single model within 5 minutes. - Failed Logins monitor: Tracks failed logins. Fires a
highsecurity log if 3 or more failed login attempts are recorded within 5 minutes. - Sensitive Module monitor: Triggers a
mediumsecurity log whenever models listed insensitive_modules(e.g.User,Role,Permission,Setting,Config) are modified. - Permission Changes: Triggers a
highsecurity log whenever a permission, role, or gate mapping is added, modified, or deleted.
π‘οΈ XSS Attack Shield
Auditify has built-in XSS protection. It automatically scans all incoming request parameters (such as $_GET or $_POST) and route variables.
If it detects common XSS patterns (like <script>, javascript:, or SVG events), it:
- Logs a critical security log entry.
- Returns an HTTP
403 Forbiddenresponse to block the request.
If you have pages that require rich text input (e.g. admin markdown or HTML editors), exclude them in your config/auditify.php file:
π Frontend Event Logging API (Optional)
[!NOTE] What is this for? Standard backend code (like Laravel/PHP) cannot see what happens inside the user's browser. Out-of-the-box, it cannot track when a user clicks a button, closes a modal, or downloads a file.
This API provides a built-in route (
/auditify/api/events) so you can easily send browser actions straight into your Activity Logs via JavaScriptβwithout needing to write your own custom API controllers and routes. You can ignore this if you don't need to track frontend actions.
How to use it:
-
Create a reusable JavaScript helper to send a
POSTrequest (which automatically attaches Laravel's CSRF security token): - Trigger it on user actions (like clicking a button or a download link):
βοΈ Vue & React Integration (SPAs)
If your application uses a frontend framework like React or Vue.js:
- Same-domain or Laravel Inertia: You can call the
/auditify/api/eventsendpoint directly usingaxiosorfetch. Session cookies and CSRF security are handled automatically by the browser. - Decoupled Setup (Different Domains): If your React/Vue frontend is hosted separately from your Laravel API:
- Add your frontend domain to the allowed origins list in Laravel's CORS configuration (
config/cors.php). - Authenticate requests via Laravel Sanctum or standard authorization headers so Auditify can link the logged events to the correct user.
- Add your frontend domain to the allowed origins list in Laravel's CORS configuration (
βοΈ React Component Example (using Axios)
π Vue 3 Component Example (using Fetch API)
π Admin-Only Access & Custom Authorization Gate
[!IMPORTANT] Who should access the logs? The Auditify log database and visual dashboard (
/auditify) contain highly sensitive information including user IP addresses, request payloads, model modifications, and security alert histories.Regular application users must never have access to this package. It is designed exclusively for system administrators, super-admins, and security officers.
By default, the package enables access control if configured in config/auditify.php. You should register an authorization callback inside your application so developers can custom-define exactly who is classified as an authorized admin.
To restrict dashboard views and log downloads to administrators only, register an authorization callback inside the boot method of your app/Providers/AppServiceProvider.php:
π¦ Installation
1. Install via Composer
Run this command in your project root:
2. Run the Installer
Run the installation command to publish configuration files, copy migrations, and set up your database automatically (this command will also automatically clear your application cache using optimize:clear):
3. Clear Application Cache (Optional)
If needed, you can manually clear all cached configuration, routes, views, and other cached data to ensure Auditify loads the latest settings:
4. Start the Laravel Development Server
If your application is not already running, start the Laravel development server:
5. Access the Dashboard
Once the installer completes successfully, open your web browser and navigate to the Auditify dashboard URL:
(Note: If you change the 'route_prefix' config setting inside config/auditify.php, this route URL will update accordingly).
4. (Optional) Selective Model Auditing
By default, Auditify automatically audits all Eloquent models globally without any manual setup.
However, if you turn off global auditing ('auto_audit_models' => false) and prefer to manually select which models to audit, add the Auditable trait:
βοΈ Configuration
After publishing, customize your settings in config/auditify.php:
π Manual Logging & Helper Methods
You can manually trigger Auditify logs or temporarily pause auditing from your own Laravel controllers, background jobs, or seeders using the Auditify facade.
[!TIP] Why use manual logging?
- Capture Intent over CRUD: Automated auditing only tracks database changes (inserts/updates). It cannot know when a user performs a non-CRUD action like downloading a PDF report, requesting a password reset, or opening a modal.
- Standardize Multi-step Workflows: Instead of cluttering logs with 10 automated database change entries during a checkout flow, you can pause automatic logging and write a single, clean entry (e.g.,
User Completed Purchase).- Log Custom Threat Metrics: Manually document custom suspicious behaviors (like rate-limit hits, coupon code abuse, or restricted API probes) using
Auditify::logSecurity.- Optimize Seeding & Imports: Turn off auditing during massive database seeding or CSV user imports to prevent database write congestion, performance lags, and log spam.
1. Manual Log Generation
Import the facade in your file:
Manually Log a Database/Module Action
Manually Log a User Activity
Manually Log a Security Alert
Real-World Controller Example
Here is a practical example of how to implement manual logging inside a standard Laravel controller, complete with code comments:
2. Pausing Auditing (Seeders & Batch Imports)
When running data migrations, database seeders, or large CSV imports, you should temporarily disable logging:
- Prevent Database Congestion (Performance): Auditing bulk inserts doubles database queries (100k records = 200k queries). Pausing logs prevents database lockups and speeds up imports.
- Prevent Table Bloat (Log Spam): Seeders generate fake mock data. Pausing auditing prevents these fake records from filling up your audit log tables and slowing down search speeds.
Option A: Running a closure (Recommended for Seeders & Migrations)
Where to use: In database/seeders/DatabaseSeeder.php or data migration files.
This helper automatically pauses auditing for the duration of the callback execution and safely restores the previous auditing state.
[!TIP] Why Option A is recommended (Exception Safe): If an error occurs inside your import/seeder logic, this helper uses an underlying PHP
finallyblock to guarantee that auditing is safely re-enabled for all subsequent requests.
Option B: Manually toggle auditing (Recommended for Artisan Commands & Test Suites)
Where to use: In custom Artisan console commands (app/Console/Commands/ImportData.php) or PHPUnit test setups (tests/TestCase.php).
Directly turns the auditing flag on or off.
[!WARNING] Use Option B with caution: If your code throws an exception after calling
disableAuditing(), it will crash before reachingenableAuditing(), leaving auditing permanently disabled on that PHP worker/process. Only use this option when a closure structure cannot be used.
π οΈ Artisan Commands
Auditify provides dedicated commands to automate installation and database size optimization:
| Command | Description |
|---|---|
auditify:install |
Runs migrations and publishes configuration files automatically. |
auditify:prune {--days=} |
Deletes old audit log records older than N days (defaults to keep_days config value). |
1. Why use the commands?
auditify:install(Simpler Onboarding): Eliminates manual setup. Rather than forcing developers to copy configurations, move migration files, and migrate tables separately, this sets up the entire package in a single terminal line.auditify:prune(Optimize DB Speed & Storage): High-traffic production systems generate millions of logs. Storing logs indefinitely slows down database queries, increases backup sizes, and increases storage costs. Pruning deletes outdated entries, ensuring instant dashboard rendering and compliance retention alignment (e.g., GDPR, SOC2).
2. Automated Database Pruning Setup
To keep database tables small and performant automatically, schedule the pruning command in your application's task scheduler in routes/console.php (or app/Console/Kernel.php):
[!TIP] Set It and Forget It: Automating the pruning command to run daily ensures your database size remains constrained and healthy without manual administrator intervention. It is recommended to schedule it during low-traffic night hours.
πΊοΈ Routes Reference
All routes are grouped under the configured route_prefix (default: auditify) with the configured middleware.
| Method | URI | Controller Action | Description |
|---|---|---|---|
| GET | / |
DashboardController@index |
Main logs dashboard index |
| GET | /action-logs |
ActionLogController@index |
View list of database action logs |
| GET | /action-logs/{id} |
ActionLogController@show |
View details with side-by-side attributes difference |
| GET | /action-logs/export/csv |
ActionLogController@exportCsv |
Export action logs in CSV format |
| GET | /action-logs/export/excel |
ActionLogController@exportExcel |
Export action logs in Excel format |
| GET | /action-logs/export/pdf |
ActionLogController@exportPdf |
Export action logs in PDF format |
| GET | /activity-logs |
ActivityLogController@index |
View list of activity logs |
| GET | /activity-logs/{id} |
ActivityLogController@show |
View activity log details |
| GET | /activity-logs/export/csv |
ActivityLogController@exportCsv |
Export activity logs in CSV format |
| GET | /activity-logs/export/excel |
ActivityLogController@exportExcel |
Export activity logs in Excel format |
| GET | /activity-logs/export/pdf |
ActivityLogController@exportPdf |
Export activity logs in PDF format |
| GET | /security-logs |
SecurityLogController@index |
View list of security logs |
| GET | /security-logs/unread-check |
SecurityLogController@checkUnreadAlerts |
Live alert poll check |
| GET | /security-logs/{id} |
SecurityLogController@show |
View security log details |
| POST | /security-logs/{id}/read |
SecurityLogController@markAsRead |
Toggle log read state |
| GET | /security-logs/export/csv |
SecurityLogController@exportCsv |
Export security logs in CSV format |
| GET | /security-logs/export/excel |
SecurityLogController@exportExcel |
Export security logs in Excel format |
| GET | /security-logs/export/pdf |
SecurityLogController@exportPdf |
Export security logs in PDF format |
| POST | /api/events |
ActivityLogController@storeFrontendEvent |
Frontend client-side interaction logging |
| GET | /reports |
ReportController@index |
View detailed log analytics and reports |
π§ͺ Testing
The package features a comprehensive PHPUnit test suite covering models, middlewares, controller endpoints, and Artisan commands. Standalone tests run via orchestra/testbench without requiring a parent Laravel installation.
Clone the repository and install development dependencies:
Run all tests:
π€ Author
Arpa Nihan
Full Stack Developer
π License
Released under the MIT License.
β If Auditify saves you time, please give it a star on GitHub! β
Made with β€οΈ for the Laravel Community
Copyright © 2026 Arpa Nihan. All rights reserved.
All versions of auditify with dependencies
maatwebsite/excel Version ^3.1
barryvdh/laravel-dompdf Version ^2.1|^3.0