PHPackages                             torgodly/visitor - 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. torgodly/visitor

ActiveLibrary

torgodly/visitor
================

Laravel visitor

v1.0(3y ago)09MITPHPPHP &gt;=7.2

Since Apr 25Pushed 3y agoCompare

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

READMEChangelog (1)Dependencies (6)Versions (2)Used By (0)

[![](resources/images/visitor.png?raw=true)](resources/images/visitor.png?raw=true)

Laravel Visitor
===============

[](#laravel-visitor)

This is a laravel package to extract and access visitors' information such as `browser`, `ip`, `device` and etc.

**In this package, you can recognize online users and determine if a user is online or not**

### Install

[](#install)

Via composer

```
composer require torgodly/visitor
```

### Configure

[](#configure)

If you are using Laravel 5.5 or higher then you don't need to add the provider and alias.

```
# In your providers array.
'providers' => [
    ...
    torgodly\Visitor\Provider\VisitorServiceProvider::class,
],

# In your aliases array.
'aliases' => [
    ...
    'Visitor' => torgodly\Visitor\Facade\Visitor::class,
],
```

Then, run the below commands to publish migrations and create tables

```
php artisan vendor:publish

php artisan migrate
```

### How to use

[](#how-to-use)

You can access to `visitor's information` using `$request->visitor()` in your controllers , and you can access to the visitor's information using `visitor()` helper function any where.

We have the below methods to retrieve a visitor's information:

- `device` : device's name
- `platform` : platform's name
- `browser` : browser's name
- `languages` : language's name
- `ip` : client's ip
- `request` : the whole request inputs
- `useragent` : the whole useragent
- `isOnline` : determines if current (or given) user is online

```
$request->visitor()->browser(); // firefox
$request->visitor()->visit($post); // create log for post
$request->visitor()->setVisitor($user)->visit($post); // create a log which says $user has visited $post
```

#### Store Logs

[](#store-logs)

You can create logs using the `visit` method like the below

```
visitor()->visit(); // create a visit log
```

use `torgodly\Visitor\Traits\Visitable` trait in your models, then you can save visit's log for your models like the below

```
// or you can save log like the below
visitor()->visit($model);
// or like the below
$model->createVisitLog();

// you can say which user has visited the given $model
$model->createVisitLog($user);
// or like the below
visitor()->setVisitor($user)->visit($model);
```

Model views can be loaded using `visits` relation.

You can count model visits like the below

```
$model->visitLogs()->count();
```

unique users can be counted by their IP and by model.

```
// by ip
$model->visitLogs()->distinct('ip')->count('ip');

// by user's model
$model->visitLogs()->visitor()->count();
```

use `torgodly\Visitor\Traits\Visitor` in your `User` class, then you can run below codes

```
$user->visit(); // create a visit log
$user->visit($model); // create a log which says, $user has visited $model
```

#### Retrieve and Determine Online users

[](#retrieve-and-determine-online-users)

use `torgodly\Visitor\Traits\Visitor` in your `User` class at first.

Then you can retrieve online users which are instance of `User` class and determine if a user is online.

```
visitor()->onlineVisitors(User::class); // returns collection of online users
User::online()->get(); // another way

visitor()->isOnline($user); // determines if the given user is online
$user->isOnline(); // another way
```

#### Automatic logging

[](#automatic-logging)

Your application can store visitor's log automatically using `LogVisits` middleware.

Add the `torgodly\Visitor\Middlewares\LogVisits` middleware if you want to save logs automatically.

The middleware will store logs for models which has binded in router (router model binding) and has used `torgodly\Visitor\Traits\Visitable` trait.

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

 Bus Factor1

Top contributor holds 56.3% 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

Unknown

Total

1

Last Release

1120d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2f00e962817b0deaca34766a21b53d6f9d2be086f5b880082e3be2a7e0ccdb7b?d=identicon)[torgodly](/maintainers/torgodly)

---

Top Contributors

[![khanzadimahdi](https://avatars.githubusercontent.com/u/6291970?v=4)](https://github.com/khanzadimahdi "khanzadimahdi (27 commits)")[![3m1n3nc3](https://avatars.githubusercontent.com/u/52163001?v=4)](https://github.com/3m1n3nc3 "3m1n3nc3 (3 commits)")[![lloricode](https://avatars.githubusercontent.com/u/8251344?v=4)](https://github.com/lloricode "lloricode (3 commits)")[![mamad55](https://avatars.githubusercontent.com/u/5247083?v=4)](https://github.com/mamad55 "mamad55 (2 commits)")[![torgodly](https://avatars.githubusercontent.com/u/57685643?v=4)](https://github.com/torgodly "torgodly (2 commits)")[![cyrildewit](https://avatars.githubusercontent.com/u/16477999?v=4)](https://github.com/cyrildewit "cyrildewit (2 commits)")[![kingispeak](https://avatars.githubusercontent.com/u/6312731?v=4)](https://github.com/kingispeak "kingispeak (1 commits)")[![mehrab-wj](https://avatars.githubusercontent.com/u/13809573?v=4)](https://github.com/mehrab-wj "mehrab-wj (1 commits)")[![mohamedsabil83](https://avatars.githubusercontent.com/u/10126040?v=4)](https://github.com/mohamedsabil83 "mohamedsabil83 (1 commits)")[![potofcoffee](https://avatars.githubusercontent.com/u/1712532?v=4)](https://github.com/potofcoffee "potofcoffee (1 commits)")[![rogermedico](https://avatars.githubusercontent.com/u/2758290?v=4)](https://github.com/rogermedico "rogermedico (1 commits)")[![roshedgostarandev1](https://avatars.githubusercontent.com/u/52368299?v=4)](https://github.com/roshedgostarandev1 "roshedgostarandev1 (1 commits)")[![bramr94](https://avatars.githubusercontent.com/u/24361182?v=4)](https://github.com/bramr94 "bramr94 (1 commits)")[![itsnasser](https://avatars.githubusercontent.com/u/32999648?v=4)](https://github.com/itsnasser "itsnasser (1 commits)")[![amirsadeghi1](https://avatars.githubusercontent.com/u/26359326?v=4)](https://github.com/amirsadeghi1 "amirsadeghi1 (1 commits)")

---

Tags

visitortrack laravel visitorstrace laravel visitorsparse laravel user agentstorgodly

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/torgodly-visitor/health.svg)

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

###  Alternatives

[shetabit/visitor

Laravel visitor

565578.2k8](/packages/shetabit-visitor)[pragmarx/tracker

A Laravel Visitor Tracker

2.9k300.0k1](/packages/pragmarx-tracker)

PHPackages © 2026

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