PHPackages                             alifcoder/activity-log - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Logging &amp; Monitoring](/categories/logging)
4. /
5. alifcoder/activity-log

ActiveLibrary[Logging &amp; Monitoring](/categories/logging)

alifcoder/activity-log
======================

A simple action activity log package for Laravel.

v1.1.12(1mo ago)01291MITPHPPHP &gt;=8.2

Since May 2Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/alifcoder/activity-log)[ Packagist](https://packagist.org/packages/alifcoder/activity-log)[ RSS](/packages/alifcoder-activity-log/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (4)Versions (31)Used By (0)

📘 Alif Activity Log
===================

[](#-alif-activity-log)

A simple, customizable Laravel package to log and store user activity across your application. Perfect for auditing, tracking changes, and monitoring actions within modules.

---

✨ Features
----------

[](#-features)

- Logs authenticated user actions and request details
- Stores activity in a dedicated `activity_logs` table
- Supports parent-child log relationships
- Customizable logging behavior
- Easily extendable and minimalistic

---

📦 Requirements
--------------

[](#-requirements)

- **PHP** `>=8.2`
- **Laravel** `^11.0 || ^12.0 || ^13.0`

---

🚀 Installation
--------------

[](#-installation)

```
composer require alifcoder/activity-log
```

---

⚙️ Configuration &amp; Migration
--------------------------------

[](#️-configuration--migration)

Publish the configuration and migration with:

```
php artisan vendor:publish --tag=activity-log
```

This will publish:

- `config/activity-log.php`
- `database/migrations/xxxx_xx_xx_xxxxxx_create_activity_logs_table.php`

Then run the migration:

```
php artisan migrate
```

---

🧑‍💻 Usage
---------

[](#‍-usage)

### Logging a manual activity

[](#logging-a-manual-activity)

```
ActivityLogger::log(new ActivityLogCreateDTO(
                log_type: 'custom',         // optional: log type
                user_id: 1,                 // optional: user_id
                url: 'http://example.com',  // optional: URL
                method: 'GET',              // optional: HTTP method
                request_body: '{}',         // optional: request body
                response_body: '{}',        // optional: response body
                ...                         // other parameters
        ));
```

🔀 Logging for Specific Routes
-----------------------------

[](#-logging-for-specific-routes)

If you want the activity logger to run **only for selected routes**, you may attach the middleware manually:

```
Route::post('/example', ExampleController::class)->middleware('activity_log');
```

---

🔐 Encrypted Request &amp; Response Storage
------------------------------------------

[](#-encrypted-request--response-storage)

All logged request and response bodies are stored as **encrypted files** for maximum data protection.

To read an encrypted stored file:

```
use Alif\ActivityLog\Facades\FileStorage;

$content = FileStorage::readEncrypted($this->request_body);
```

---

🔑 Generating an Encryption Secret Key
-------------------------------------

[](#-generating-an-encryption-secret-key)

Since request/response data is encrypted, the package requires a secret key.

Generate it using:

```
php artisan activity-log:generate-key
```

---

🌍 IP Address Details Sync
-------------------------

[](#-ip-address-details-sync)

The package supports collecting additional information about user IP addresses, such as:

- Country
- City
- Coordinates
- ISP
- ASN
- and more

After installation, the package automatically registers a scheduled task:

```
php artisan activity-log:sync-ip-details
```

---

🧹 Pruning Old Logs
------------------

[](#-pruning-old-logs)

To automatically delete old or unnecessary logs, the package provides pruning support.

Add the following to your application's scheduler:

```
$schedule->command('model:prune', [
    '--model' => [Alif\ActivityLog\Models\ActivityLog::class],
])->daily();
```

---

🧱 Table Structure: `activity_logs`
----------------------------------

[](#-table-structure-activity_logs)

ColumnTypeDescription`id`UUIDPrimary key`parent_id`UUIDLink to parent log (optional)`log_type`StringType of action (e.g. create)`user_id`StringAuthenticated user ID`module`StringApp module or context`route`StringRoute name`url`StringFull URL accessed`model_id`StringRelated model ID (optional)`model_type`StringRelated model class (optional)`user_agent`TextBrowser/user-agent string`created_at`DateTimeWhen the log was created---

🧹 Uninstall (Clean Up)
----------------------

[](#-uninstall-clean-up)

Run this command before removing the package:

```
php artisan activity-log:uninstall
```

It will:

- Roll back the migration (calls `down()`)
- Delete related migration files
- Remove the config file

Then remove the package:

```
composer remove alifcoder/activity-log
```

---

🤝 Contributing
--------------

[](#-contributing)

Pull requests are welcome! For major changes, please open an issue first.

---

🪪 License
---------

[](#-license)

MIT License © [Shukhratjon Yuldashev](https://t.me/alif_coder)

---

📡 Automatic Logging for All Requests
------------------------------------

[](#-automatic-logging-for-all-requests)

To log **every request** made to your Laravel application, you can use the provided middleware and HTTP macro.

### ✅ 1. Register the Middleware

[](#-1-register-the-middleware)

In your `app/Http/Kernel.php`, register the middleware globally or per group:

```
protected $middleware = [
    // ...
    \Alif\ActivityLog\Http\Middleware\ActivityLogMiddleware::class,
];
```

This will automatically log incoming HTTP requests, including route, URL, method, and user info.

### ✅ 2. Log Outgoing HTTP Requests

[](#-2-log-outgoing-http-requests)

The package extends Laravel’s `Http` client with a `loggable()` macro.

Example usage:

```
use Illuminate\Support\Facades\Http;

$response = Http::loggable()->get('https://example.com/api/data');
```

This logs outgoing HTTP calls made by your application.

---

🧩 Customization
---------------

[](#-customization)

You can customize what gets logged, ignored routes/methods, and the database connection via:

```
config/activity-log.php

```

---

📫 Support
---------

[](#-support)

If you need help, feel free to contact [Shukhratjon Yuldashev on Telegram](https://t.me/alif_coder).

###  Health Score

47

—

FairBetter than 94% of packages

Maintenance90

Actively maintained with recent releases

Popularity14

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~12 days

Recently: every ~31 days

Total

29

Last Release

48d ago

PHP version history (2 changes)v1.0.0PHP ^8.2

v1.0.1PHP &gt;=8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/69b6b7d063b766d3399fad3f23d2407d6f8d4abafe9ce6b7f5e2fd813b93984b?d=identicon)[alifcoder](/maintainers/alifcoder)

---

Top Contributors

[![Sardorbek1605](https://avatars.githubusercontent.com/u/69075522?v=4)](https://github.com/Sardorbek1605 "Sardorbek1605 (25 commits)")[![iamshukhrat](https://avatars.githubusercontent.com/u/61014049?v=4)](https://github.com/iamshukhrat "iamshukhrat (22 commits)")[![alifcoder](https://avatars.githubusercontent.com/u/94315908?v=4)](https://github.com/alifcoder "alifcoder (10 commits)")[![khamdullaevuz](https://avatars.githubusercontent.com/u/81905341?v=4)](https://github.com/khamdullaevuz "khamdullaevuz (3 commits)")

### Embed Badge

![Health badge](/badges/alifcoder-activity-log/health.svg)

```
[![Health](https://phpackages.com/badges/alifcoder-activity-log/health.svg)](https://phpackages.com/packages/alifcoder-activity-log)
```

###  Alternatives

[spatie/laravel-health

Monitor the health of a Laravel application

85810.0M83](/packages/spatie-laravel-health)[beyondcode/laravel-server-timing

Add Server-Timing header information from within your Laravel apps.

5712.0M1](/packages/beyondcode-laravel-server-timing)[rollbar/rollbar-laravel

Rollbar error monitoring integration for Laravel projects

14110.4M7](/packages/rollbar-rollbar-laravel)[yadahan/laravel-authentication-log

Laravel Authentication Log provides authentication logger and notification for Laravel.

416632.8k5](/packages/yadahan-laravel-authentication-log)[stechstudio/laravel-metrics

Easily track metrics from Laravel events, or on your own

50211.7k](/packages/stechstudio-laravel-metrics)[kitloong/laravel-app-logger

Laravel log for your application

101.2M8](/packages/kitloong-laravel-app-logger)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
