PHPackages                             rajuez/activitylog - 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. rajuez/activitylog

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

rajuez/activitylog
==================

A very simple activity logger to monitor the users of your website or application

2.0.4(10y ago)1163MITPHPPHP &gt;=5.4.0

Since May 6Pushed 10y ago2 watchersCompare

[ Source](https://github.com/RajuEz/activitylog)[ Packagist](https://packagist.org/packages/rajuez/activitylog)[ RSS](/packages/rajuez-activitylog/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (13)Used By (0)

Log the activity of your users - (Modified for Personnel use)
=============================================================

[](#log-the-activity-of-your-users---modified-for-personnel-use)

[![Latest Version](https://camo.githubusercontent.com/1c2e179d6d25b4c3fcfb7b455606dab0ce4417b16577faf456c5fae081d4fa8d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f667265656b6d75727a652f61637469766974796c6f672e7376673f7374796c653d666c61742d737175617265)](https://github.com/freekmurze/activitylog/releases)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/4da2ac00cba5de2ca6e9ebcf57ef33a9899e011f7d49957e16fae6099ec49856/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f667265656b6d75727a652f61637469766974796c6f672f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/freekmurze/activitylog)[![SensioLabsInsight](https://camo.githubusercontent.com/1fcaac7e37637706e32c3c5407870a0042a1eef2335d566ced45490d86013ab9/68747470733a2f2f696d672e736869656c64732e696f2f73656e73696f6c6162732f692f63343838303963372d636462332d346538362d393734622d6164396336323832626333632e737667)](https://insight.sensiolabs.com/projects/c48809c7-cdb3-4e86-974b-ad9c6282bc3c)[![Total Downloads](https://camo.githubusercontent.com/33d0b4ac423346a03360988c4952aeeb8544e6887fc922fc62fb09e88aa009dc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7370617469652f61637469766974796c6f672e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spatie/activitylog)

This Laravel 5 package provides a very easy to use solution to log the activities of the users of your Laravel 5 app. All the activities will be logged in a db-table. Optionally the activities can also be logged against the default Laravel Log Handler.

Created by [Freek Van der Herten](https://murze.be) ([@freekmurze](https://twitter.com/freekmurze))

### Note:

[](#note)

If you're using Laravel 4, take a look at version 0.3.0 of this package.

Installation
------------

[](#installation)

This package can be installed through Composer.

```
composer require spatie/activitylog
```

This service provider must be registered.

```
// config/app.php

'providers' => [
    '...',
    'Spatie\Activitylog\ActivitylogServiceProvider',
];
```

You'll also need to publish and run the migration in order to create the db-table.

```
php artisan vendor:publish --provider="Spatie\Activitylog\ActivitylogServiceProvider" --tag="migrations"
php artisan migrate

```

Activitylog also comes with a facade, which provides an easy way to call it.

```
// config/app.php

'aliases' => [
	...
	'Activity' => 'Spatie\Activitylog\ActivitylogFacade',
];
```

Optionally you can publish the config file of this package.

```
php artisan vendor:publish --provider="Spatie\Activitylog\ActivitylogServiceProvider" --tag="config"

```

The configuration will be written to `config/activitylog.php`. The options provided are self explanatory.

Usage
-----

[](#usage)

### Manual logging

[](#manual-logging)

Logging some activity is very simple.

```
/*
  The log-function takes two parameters:
  	- $text: the activity you wish to log.
  	- $user: optional can be an user id or a user object.
  	         if not proved the id of Auth::user() will be used

*/
Activity::log('Some activity that you wish to log');
```

The string you pass to function gets written in a db-table together with a timestamp, the ip address and the user agent of the user.

### Log model events

[](#log-model-events)

This package can log the events from your models. To do so your model must use the `LogsActivity`-trait and implement `LogsActivityInterface`.

```
use Spatie\Activitylog\LogsActivityInterface;
use Spatie\Activitylog\LogsActivity;

class Article implements LogsActivityInterface {

   use LogsActivity;
...
```

The interface expects you to implement the `getActivityDescriptionForEvent`-function.

Here's an example of a possible implementation.

```
/**
 * Get the message that needs to be logged for the given event name.
 *
 * @param string $eventName
 * @return string
 */
public function getActivityDescriptionForEvent($eventName)
{
    if ($eventName == 'created')
    {
        return 'Article "' . $this->name . '" was created';
    }

    if ($eventName == 'updated')
    {
        return 'Article "' . $this->name . '" was deleted';
    }

    if ($eventName == 'deleted')
    {
        return 'Article "' . $this->name . '" was deleted';
    }

    return '';
}
```

The result of this function will be logged, unless the result is an empty string.

### Retrieving logged entries

[](#retrieving-logged-entries)

All events will be logged in the `activity_log`-table. This package provides an Eloquent model to work with the table. You can use all the normal Eloquent methods that you know and love. Here's how you can get the last 100 activities together with the associated users.

```
use Spatie\Activitylog\Models\Activity;

$latestActivities = Activity::with('user')->latest()->limit(100)->get();
```

### Cleaning up the log

[](#cleaning-up-the-log)

Over time your log will grow. To clean up the database table you can run this command:

```
Activity::cleanLog();
```

By default records older than 2 months will be deleted. The number of months can be modified in the config-file of the package.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Freek Van der Herten](https://github.com/freekmurze)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 80.8% 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 ~35 days

Recently: every ~14 days

Total

12

Last Release

4010d ago

Major Versions

0.3.0 → 1.0.02015-02-05

1.0.1 → 2.0.02015-04-01

### Community

Maintainers

![](https://www.gravatar.com/avatar/390f0f4b51268c6a672b5b2f453fdeeb0fdcbe52bf60e5ee11296e527301b779?d=identicon)[RajuEz](/maintainers/RajuEz)

---

Top Contributors

[![freekmurze](https://avatars.githubusercontent.com/u/483853?v=4)](https://github.com/freekmurze "freekmurze (59 commits)")[![rajpraiyalan](https://avatars.githubusercontent.com/u/7474046?v=4)](https://github.com/rajpraiyalan "rajpraiyalan (12 commits)")[![MatthiasDeWinter](https://avatars.githubusercontent.com/u/8791525?v=4)](https://github.com/MatthiasDeWinter "MatthiasDeWinter (2 commits)")

---

Tags

loglaraveluseractivity

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/rajuez-activitylog/health.svg)

```
[![Health](https://phpackages.com/badges/rajuez-activitylog/health.svg)](https://phpackages.com/packages/rajuez-activitylog)
```

###  Alternatives

[spatie/laravel-activitylog

A very simple activity logger to monitor the users of your website or application

5.8k45.4M309](/packages/spatie-laravel-activitylog)[msonowal/laravel-auditor

A simple mongo activity logger to record various events of your laravel application

1030.2k1](/packages/msonowal-laravel-auditor)

PHPackages © 2026

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