Download the PHP package abdulbaset/activity-tracker without Composer
On this page you can find all versions of the php package abdulbaset/activity-tracker. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download abdulbaset/activity-tracker
More information about abdulbaset/activity-tracker
Files in abdulbaset/activity-tracker
Package activity-tracker
Short Description A comprehensive activity Tracker for Laravel projects.
License MIT
Homepage https://digitalatum.com
Informations about the package activity-tracker
Activity Tracker for Laravel
Activity Tracker is a comprehensive logging package for Laravel projects, designed to track various activities within your application. It provides functionality to log events such as entity creation, updates, deletions, and retrievals, along with additional contextual information like user ID, IP address, device type, and more.
Table of Contents
- Activity Tracker for Laravel
- Table of Contents
- Installation
- Install
- Configuration
- Migrations
- Usage
- Logging Events Directly
- Using Traits
- Using Observers
- Examples
- Features
- Author
- Contributing
- License
Installation
Install
You can install the Activity Tracker package via Composer. Run the following command in your terminal:
To update the Activity Tracker package in your Laravel project, you can use Composer's update command. Here's how you can do it:
After running the update command in your Laravel project directory, and Composer will check for updates to the abdulbaset/activity-tracker package and its dependencies. If a newer version is available, Composer will download and install it, updating your project.
Configuration
After installing the package, publish the configuration file using the following command:
You can configure the Activity Tracker package by modifying the config/activity-tracker.php file. This file allows you to specify settings such as the log table name, log method (database or file), log file path, etc.
Migrations
After installing the package, you need to run the migrations to create the required database tables. To do this, use the following Artisan command:
-
Running Migrations for Specific Tables
-
Rolling Back Specific Migrations
- Refreshing Migrations for Specific Tables
Usage
There are multiple ways to integrate the Activity Tracker package into your Laravel application, allowing you to track various activities and events within your system, These three methods provide flexibility in how you integrate the Activity Tracker package into your Laravel application, allowing you to choose the approach that best fits your project's requirements.
Logging Events Directly
To log events directly in your application code, you can use the ActivityTracker
facade provided by the package. Here's an example of how to log an event:
In this example, Model::class represents the entity being logged, 'retrieved' is the event type, 'Entity retrieved' is the event description, and ['example_key' => 'example value'] is additional information associated with the event.
Using Traits
With the ActivityTrackerTrait trait applied, you can call methods like logCreated, logUpdated, and logDeleted directly on your model instances:
Using Observers
The Activity Tracker Observer allows you to automatically log events when certain actions are performed on your models. To use the Activity Tracker Observer:
Examples
For usage examples and code snippets.
-
if you need use in Controller following example.
-
if you need use by Trait inside model following example.
-
if you need use by Observer following example.
- if you want make customized Observer following example.
and assign inside boot method at AppServiceProvider namespace
Features
- Comprehensive Activity Logging: Track various user actions such as create, update, delete, and etc.. operations on models.
- Flexible Configuration: Customize logging behavior with configuration options such as log method (database or file), log file path.
- Automatic Login and Logout Tracking: Automatically log user login and logout events with configurable options.
- Event-Specific Data Logging: Log event-specific data such as changes made during updates, old and new values, IP address, browser details, and more.
- Support for Laravel: Use the package seamlessly with Laravel applications.
- Trait and Observer Support: Easily integrate activity logging into your models using provided traits or observers.
- Easy to Use: Simple API for logging activities, making it straightforward to implement in your application.
- Custom Event Logging: Extend the functionality by adding custom event listeners to log additional events specific to your application.
- Configurable: Configure the package to suit your application's requirements, including enabling or disabling specific logging features.
Author
The Activity Tracker package was created by Abdulbaset R. Sayed [email protected]
Contributing
Contributions are welcome! If you encounter any issues or have suggestions for improvements, feel free to open an issue or submit a pull request on GitHub.
License
This Package is licensed under the MIT License - see the LICENSE file for details.