PHPackages                             sagor/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. sagor/activity-log

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

sagor/activity-log
==================

A simple but powerfull package to log user activities in Laravel.

v1.0.7(6mo ago)029MITPHPPHP &gt;=7.2

Since Oct 14Pushed 6mo agoCompare

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

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

🧾 Sagor Activity Log
====================

[](#-sagor-activity-log)

[![Packagist Version](https://camo.githubusercontent.com/3a5fc493f06fcdee7c19c41608fb7795c32317c96072a1c68aa42eeb99296165/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7361676f722f61637469766974792d6c6f672e737667)](https://packagist.org/packages/sagor/activity-log)![Laravel Version](https://camo.githubusercontent.com/23729853e31f19fd2289f12f4bb42bd4918d6d65398a3449539e318a5d5e6bad/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d352e782d2d31322e782d6f72616e6765)![PHP Version](https://camo.githubusercontent.com/02ae8e6fab238b4fc56f55e59d02b9f60c46b10805daca9d2d6c679dce81f50c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d372e322d2d382e342d626c7565)![License](https://camo.githubusercontent.com/5caa455d8debc46fb23abbadb45a733a937f3910a73fc875c2f7820468e1bb54/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d677265656e)

A **zero-configuration Laravel package** to automatically log user activities, model changes, HTTP requests, and authentication events. Everything works **out-of-the-box**, no manual setup required.

---

📌 Compatibility
---------------

[](#-compatibility)

- **Laravel:** 5.x - 12.x
- **PHP:** 7.2 - 8.4

---

⚡ Features
----------

[](#-features)

- Automatic logging of all Eloquent model events (`created`, `updated`, `deleted`, `restored`)
- Logs user login and logout events
- Logs HTTP requests that modify data (`POST`, `PUT`, `PATCH`, `DELETE`)
- Manual logging with the `activity()` helper
- No configuration required

---

🛠 Installation and Setup (Full Process)
---------------------------------------

[](#-installation-and-setup-full-process)

1. **Install via Composer**

```
composer require sagor/activity-log
```

2. **Run Migration**

The package automatically provides a migration. Run:

```
php artisan migrate
```

This will create a table called `automatic_activity_log` with the following structure:

ColumnTypeDescriptionidbigintPrimary keycauser\_typestringType of the user or system causing the action (polymorphic)causer\_idbigintID of the user or system causing the action (polymorphic)action\_typestringType of activity (e.g., created, updated, deleted)descriptionlongTextDescription of the activityaffected\_model\_typestringType of the affected model (polymorphic)affected\_model\_idbigintID of the affected model (polymorphic)ip\_addressstringIP address of the user performing the actionuser\_agenttextUser agent of the requesterurlstringURL where the action occurredmethodstringHTTP method usedcreated\_attimestampLog creation timeupdated\_attimestampLog update time3. **How It Works**

The package automatically listens to Laravel events:

- `eloquent.*` → logs all model events (`created`, `updated`, `deleted`, `restored`)
- `Illuminate\Auth\Events\Login` &amp; `Logout` → logs authentication events
- `Illuminate\Foundation\Http\Events\RequestHandled` → logs `POST`, `PUT`, `PATCH`, `DELETE` requests

All activities are stored automatically in the `automatic_activity_log` table. **No manual calls needed.**

---

✍️ Manual Logging Example
-------------------------

[](#️-manual-logging-example)

If you want to log custom actions, you can use the `activity()` helper:

```
activity()
    ->causedBy(auth()->user())  // The user performing the action
    ->performedOn($someModel)   // The affected model
    ->withType('custom')        // Custom type (optional)
    ->log('A custom action was performed.'); // Description
```

Example:

```
// Log a manual update for a post
activity()
    ->causedBy(auth()->user())
    ->performedOn($post)
    ->withType('custom')
    ->log('Updated a post manually.');
```

---

📚 Full Usage Flow
-----------------

[](#-full-usage-flow)

1. Install the package with Composer
2. Run `php artisan migrate` to create the log table
3. Automatically track:

- All model changes
- User login/logout events
- HTTP requests that modify data

4. Optionally, log custom actions using `activity()` helper
5. Check the `automatic_activity_log` table for logs

**No additional configuration is needed.** Just install, migrate, and it works.

---

Route with controller
---------------------

[](#route-with-controller)

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

Route::get('/activity-log', function (Request $request) {
    $query = DB::table('automatic_activity_log')->orderBy('created_at', 'desc');

    // Apply search filter if provided
    if ($request->filled('search')) {
        $search = $request->search;
        $query->where('description', 'like', "%{$search}%")
              ->orWhere('action_type', 'like', "%{$search}%")
              ->orWhere('causer_type', 'like', "%{$search}%")
              ->orWhere('affected_model_type', 'like', "%{$search}%");
    }

    // Paginate results
    $logs = $query->paginate(10)->withQueryString();

    return view('activity-log', compact('logs', 'request'));
});

```

Blade with Filter and pagination
--------------------------------

[](#blade-with-filter-and-pagination)

```
@extends('layouts.app')

@section('title', 'Activity Log')

@section('content')

    Activity Logs

            Search

                ID
                Causer
                Action Type
                Description
                Affected Model
                IP Address
                User Agent
                URL
                Method
                Created At

            @forelse ($logs as $log)

                {{ $log->id }}
                {{ $log->causer_type }} #{{ $log->causer_id }}
                {{ $log->action_type }}
                {{ $log->description }}
                {{ $log->affected_model_type }} #{{ $log->affected_model_id }}
                {{ $log->ip_address }}
                {{ $log->user_agent }}
                {{ $log->url }}
                {{ $log->method }}
                {{ $log->created_at }}

            @empty

                No logs found.

            @endforelse

        {{ $logs->links() }}

@endsection

```

🛡 License
---------

[](#-license)

MIT License. See the LICENSE file for details.

---

👤 Author
--------

[](#-author)

**Md Sagor Hossain**Email: GitHub:

---

🚀 Contributing
--------------

[](#-contributing)

1. Fork the repository
2. Create a feature branch: `git checkout -b feature/AmazingFeature`
3. Commit your changes: `git commit -m 'Add some AmazingFeature'`
4. Push to the branch: `git push origin feature/AmazingFeature`
5. Open a Pull Request

---

🎯 Support
---------

[](#-support)

If you like this package, give it a ⭐ on GitHub!

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance66

Regular maintenance activity

Popularity7

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity35

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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 ~1 days

Total

8

Last Release

208d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/d211e416041359c99f37b12f9dfd70c1314ea5ae3df4470e15800ac8fc904daa?d=identicon)[moh-sagor](/maintainers/moh-sagor)

---

Top Contributors

[![moh-sagor](https://avatars.githubusercontent.com/u/48994376?v=4)](https://github.com/moh-sagor "moh-sagor (8 commits)")

---

Tags

laravelartisangithubgitactivitylog

### Embed Badge

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

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

###  Alternatives

[laravel/passport

Laravel Passport provides OAuth2 server support to Laravel.

3.4k85.0M532](/packages/laravel-passport)[yadahan/laravel-authentication-log

Laravel Authentication Log provides authentication logger and notification for Laravel.

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

Laravel Pulse is a real-time application performance monitoring tool and dashboard for your Laravel application.

1.7k12.1M99](/packages/laravel-pulse)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[laragear/two-factor

On-premises 2FA Authentication for out-of-the-box.

339785.3k8](/packages/laragear-two-factor)[essa/api-tool-kit

set of tools to build an api with laravel

52680.5k](/packages/essa-api-tool-kit)

PHPackages © 2026

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