abhimanyu/hive
最新稳定版本:v1.0.0
Composer 安装命令:
composer require abhimanyu/hive
包简介
Hive is a lightweight yet powerful Laravel package designed to track and log user activities across your application. Whether it's page views, logins, form submissions, or custom events, Hive provides real-time insights into user behavior, helping you enhance analytics, improve debugging, and ensure
README 文档
README
This document provides detailed steps for installing and configuring the Laravel User Activity package, along with guidelines for setting up the package repository for Git.
1. Installation
Step 1: Install via Composer
Run the following command to install the package via Composer:
composer require abhimanyu/hive
2. Configuration
Step 2.1: Publish Configuration File
Run the following command to publish the package's configuration file:
php artisan vendor:publish --tag=config --provider="Abhimanyu\Hive\UserActivityServiceProvider"
This will create a file config/user_activity.php. Customize the configuration according to your requirements.
Step 2.2: Publish Migrations
Publish the database migration files using the command:
php artisan vendor:publish --tag=migrations --provider="Abhimanyu\Hive\UserActivityServiceProvider"
Run the migrations to create the necessary database table:
php artisan migrate
Step 2.3: Add Middleware
To enable activity tracking globally, register the middleware in app/Http/Kernel.php:
protected $middlewareGroups = [ 'web' => [ \Abhimanyu\Hive\Middleware\TrackUserActivity::class, ], ];
Step 2.4: Load Routes (Optional)
The package automatically loads its routes. To customize them, include the routes manually in your routes/web.php:
require base_path('vendor/abhimanyu/hive/src/routes/web.php');
3. Usage
Log User Activity
You can log custom user activities using the ActivityLogger service:
use Abhimanyu\Hive\Services\ActivityLogger; ActivityLogger::log(auth()->user(), 'Exported activity logs');
4. Publishing Assets
To publish the views for customization, run:
php artisan vendor:publish --tag=views --provider="Abhimanyu\Hive\UserActivityServiceProvider"
5. Git Repository Setup
Step 5.1: Initialize Git Repository
Initialize the Git repository in the package directory:
git init
Step 5.2: Create .gitignore
Add a .gitignore file in the root directory with the following content:
/vendor
/node_modules
/.env
/.idea
/.vscode
/public/storage
/storage/*.key
Step 5.3: Add All Files
Stage all files for the initial commit:
git add .
Step 5.4: Commit Changes
Create an initial commit:
git commit -m "Initial commit of Laravel User Activity package"
Step 5.5: Add Remote Repository
Add your Git remote repository:
git remote add origin <your-repository-url>
Step 5.6: Push Code
Push your code to the remote repository:
git push -u origin main
统计信息
- 总下载量: 3
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-12-24