PHPackages                             kim/activity - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. kim/activity

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

kim/activity
============

Easily retrieve a list of users and guests that are online.

1.1.0(10y ago)12830.4k↓50%30[7 issues](https://github.com/thomastkim/laravel-online-users/issues)[1 PRs](https://github.com/thomastkim/laravel-online-users/pulls)MITPHPPHP &gt;=5.5.9CI failing

Since Oct 19Pushed 9y ago10 watchersCompare

[ Source](https://github.com/thomastkim/laravel-online-users)[ Packagist](https://packagist.org/packages/kim/activity)[ Docs](https://github.com/thomastkim/laravel-online-users)[ RSS](/packages/kim-activity/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (5)Versions (7)Used By (0)

See Who's Online With This Laravel Package
==========================================

[](#see-whos-online-with-this-laravel-package)

With this package, you can easily see who's online and how many guests are viewing your site.

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

[](#installation)

To install this package, just follow these quick few steps.

### Composer

[](#composer)

As always, pull this package through composer by opening `composer.json` file and adding this within `require`:

```
"kim/activity": "^1.1"

```

Note: If you are running Laravel 5.0 or 5.1, please require version "^1.0".

Afterward, run either `composer update`.

### Providers and Aliases

[](#providers-and-aliases)

Next, open `config/app.php` and add this to your providers array:

```
Kim\Activity\ActivityServiceProvider::class

```

and this to your aliases array:

```
'Activity' => Kim\Activity\ActivityFacade::class

```

### Session and Database Setup

[](#session-and-database-setup)

Finally, you need to change your session configuration to use the database. Open the `.env` file, which should be at the root directory of your Laravel project. Then, change your session driver to database.

```
SESSION_DRIVER=database

```

If you are running L5.2, publish the default session migrations file and then migrate it by running these commands:

```
php artisan session:table

php artisan migrate

```

If you are running L5.0 or L5.1, run these commands:

```
php artisan vendor:publish --provider="Kim\Activity\ActivityServiceProvider" --tag="migrations"

php artisan migrate

```

Usage
-----

[](#usage)

This package will automatically update a user's or guest's most recent activity. To grab the most recent users and guests though, you can use the easy-to-use built-in methods.

### Grabbing Most Recent Activities

[](#grabbing-most-recent-activities)

Import the Activity facade at the top and then do a simple query.

```
// Import at the top
use Activity;

// Find latest users
$activities = Activity::users()->get();

// Loop through and echo user's name
foreach ($activities as $activity) {
    echo $activity->user->name . '';
}

```

The `users` method will grab the most recent activities within the past 5 minutes. You can change the default timespan by specifying the minutes.

```
$activities = Activity::users(1)->get();   // Last 1 minute
$activities = Activity::users(10)->get();  // Last 10 minutes
$activities = Activity::users(60)->get();  // Last 60 minutes

```

You have other methods for your convenience to grab the latest activities by seconds or even hours.

```
$activities = Activity::usersBySeconds(30)->get();  // Get active users within the last 30 seconds
$activities = Activity::usersByMinutes(10)->get();  // Get active users within the last 10 minutes
$activities = Activity::usersByHours(1)->get();     // Get active users within the last 1 hour

$numberOfUsers = Activity::users()->count();        // Count the number of active users

```

### Sorting Methods

[](#sorting-methods)

In order to sort the activities by most and least recent, just use the `mostRecent` and `leastRecent` methods.

```
$activities = Activity::users()->mostRecent()->get();   // Get active users and sort them by most recent
$activities = Activity::users()->leastRecent()->get();  // Get active users and sort them by least recent

```

In addition to this, you can sort the user's attributes by using the `orderByUsers` method. For example, rather than ordering by the most recent activity, lets say you want to order by the users' name alphabetically. You can do this.

```
$activities = Activity::users()->orderByUsers('email')->get();

```

### Grabbing the Guests

[](#grabbing-the-guests)

In order to grab the number of guests that are online, it's just as intuitive as grabbing the users. For example:

```
$numberOfGuests = Activity::guests()->count();      // Count the number of active guests

```

License
-------

[](#license)

This package is free software distributed under the terms of the MIT license.

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity43

Moderate usage in the ecosystem

Community15

Small or concentrated contributor base

Maturity62

Established project with proven stability

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

Total

6

Last Release

3619d ago

Major Versions

1.0.3 → 5.1.x-dev2016-06-20

PHP version history (2 changes)1.0.0PHP &gt;=5.4.0

1.1.0PHP &gt;=5.5.9

### Community

Maintainers

![](https://www.gravatar.com/avatar/ca22d30322941193b0ebbe83b7594997efcf5ba83da563c32f210e541cd660a3?d=identicon)[thomastkim](/maintainers/thomastkim)

---

Top Contributors

[![thomastkim](https://avatars.githubusercontent.com/u/8099546?v=4)](https://github.com/thomastkim "thomastkim (13 commits)")

---

Tags

phplaravelonline activity

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[monicahq/laravel-cloudflare

Add Cloudflare ip addresses to trusted proxies for Laravel.

3372.7M4](/packages/monicahq-laravel-cloudflare)[kra8/laravel-snowflake

Snowflake for Laravel and Lumen.

188402.3k6](/packages/kra8-laravel-snowflake)[tehwave/laravel-achievements

Simple, elegant Achievements the Laravel way

7012.8k](/packages/tehwave-laravel-achievements)[joshrainwater/active-users

A Laravel Package for easily retrieving a list of active users and guests that are currently online.

9119.8k](/packages/joshrainwater-active-users)[bjuppa/laravel-blog

Add blog functionality to your Laravel project

483.3k2](/packages/bjuppa-laravel-blog)

PHPackages © 2026

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