PHPackages                             tatter/visits - 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. tatter/visits

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

tatter/visits
=============

Lightweight traffic tracking for CodeIgniter 4

v2.0.0(2y ago)338.6k↓31.3%11[1 PRs](https://github.com/tattersoftware/codeigniter4-visits/pulls)2MITPHPPHP ^7.4 || ^8.0

Since Mar 25Pushed 1y ago4 watchersCompare

[ Source](https://github.com/tattersoftware/codeigniter4-visits)[ Packagist](https://packagist.org/packages/tatter/visits)[ Docs](https://github.com/tattersoftware/codeigniter4-visits)[ Fund](https://paypal.me/tatter)[ GitHub Sponsors](https://github.com/tattersoftware)[ RSS](/packages/tatter-visits/feed)WikiDiscussions develop Synced today

READMEChangelog (10)Dependencies (4)Versions (18)Used By (2)

Tatter\\Visits
==============

[](#tattervisits)

Lightweight traffic tracking for CodeIgniter 4

[![](https://github.com/tattersoftware/codeigniter4-visits/workflows/PHPUnit/badge.svg)](https://github.com/tattersoftware/codeigniter4-visits/actions/workflows/phpunit.yml)[![](https://github.com/tattersoftware/codeigniter4-visits/workflows/PHPStan/badge.svg)](https://github.com/tattersoftware/codeigniter4-visits/actions/workflows/phpstan.yml)[![](https://github.com/tattersoftware/codeigniter4-visits/workflows/Deptrac/badge.svg)](https://github.com/tattersoftware/codeigniter4-visits/actions/workflows/deptrac.yml)[![Coverage Status](https://camo.githubusercontent.com/e897b132ae59b569a17fd01de2e4a07081dcb20f786b6d6f515ee7e3a3caff88/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f746174746572736f6674776172652f636f646569676e69746572342d7669736974732f62616467652e7376673f6272616e63683d646576656c6f70)](https://coveralls.io/github/tattersoftware/codeigniter4-visits?branch=develop)

Quick Start
-----------

[](#quick-start)

1. Install with Composer: `> composer require tatter/visits`
2. Update the database: `> php spark migrate --all`
3. Apply the `visits` filter in **app/Config/Filters.php**:

```
class Filters extends BaseConfig
{
    public $globals = [
        'after' => ['visits'],
    ];
...
```

Features
--------

[](#features)

Provides automated traffic tracking for CodeIgniter 4

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

[](#installation)

Install easily via Composer to take advantage of CodeIgniter 4's autoloading capabilities and always be up-to-date:

```
> composer require tatter/visits
```

Or, install manually by downloading the source files and adding the directory to **app/Config/Autoload.php**.

Once the files are downloaded and included in the autoload, run any library migrations to ensure the database is set up correctly:

```
> php spark migrate --all
```

Configuration (optional)
------------------------

[](#configuration-optional)

The library's default behavior can be altered by extending its config file. Copy **examples/Visits.php** to **app/Config/** and follow the instructions in the comments. If no config file is found in **app/Config/** the library will use its own.

### Customization

[](#customization)

The config file allows for some basic control over what gets counted as a "hit".

- `$ignoreAjax`: Whether to ignore AJAX requests when recording

Filtering by AJAX requests is not a guaranteed business; read more in the [User Guide](https://www.codeigniter.com/user_guide/general/ajax.html).

If you are using the `after` filter method it is also possible to adjust some behaviors based on the application's Response instance:

- `$ignoreRedirects`: Whether to ignore requests that result in a redirect response
- `$requireBody`: Whether to ignore requests that result in an empty body
- `$requireHtml`: Whether to ignore requests with Content Types other than HTML

Usage
-----

[](#usage)

The main function of this library is applied through a [Controller Filter](https://codeigniter4.github.io/CodeIgniter4/incoming/filters.html). The `VisitsFilter` is pre-aliased for you as `visits` but needs to be applied to whichever routes you would like to track. Read the User Guide for more details, but in most cases applying the filter globally will be the best fit:

```
// app/Config/Filters.php

class Filters extends BaseConfig
{
    public $globals = [
        'before' => [
            'csrf',
        ],
        'after' => [
            'visits',
        ],
    ];

    // ...
}
```

The filter can be applied to either `before` or `after` methods, with the following expectations:

- `before` filtering is likely to record more nuances in traffic (such as page loads before an error occurs) but they are less customizable
- `after` filtering allows for finer control over what counts as a "hit" but may miss some instances captured by `before`

Applying both `before` and `after` will duplicate your traffic information and should not be done.

Accessing data
--------------

[](#accessing-data)

This library provides a `VisitModel` and a `Visit` entity for convenient access to recorded entries. Feel free to extend these classes for any additional functionality.

Transformers
------------

[](#transformers)

Before a visit is assessed for similar and recorded it may be passed through any number of transformations. A transformer is a class that implements `Tatter\Visits\Interfaces\Transformer`and has the single static method for applying a transformation:

```
public static function transform(Visit $visit, IncomingRequest $request): ?Visit;
```

Transformers work on the `Visit` class they are passed, and return either the modified `Visit` instance or `null` to indicate "don't record this visit" and halt operation. If a modified `Visit` is returned it will be passed into the next Transformer and so on.

To active Transformers and set their order simply add them to the `$transformers` property of the config file:

```
use App\Transformers\AnonymousTransformer;

class Visits extends BaseConfig
{
    public array $transformers = [
        AnonymousTransformer::class,
    ];
}
```

User tracking
-------------

[](#user-tracking)

**Visits** will use any Composer package that provides `codeigniter4/authentication-implementation`to identify an active user. It is not legal nor advisable to track user traffic in all cases, so make sure you are configuring your project appropriately for local laws and regulations. Filtering and anonymizing data to meet tighter specifications can be accomplished with Transformers.

###  Health Score

42

—

FairBetter than 88% of packages

Maintenance29

Infrequent updates — may be unmaintained

Popularity32

Limited adoption so far

Community21

Small or concentrated contributor base

Maturity74

Established project with proven stability

 Bus Factor1

Top contributor holds 95.7% 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 ~126 days

Recently: every ~144 days

Total

15

Last Release

880d ago

Major Versions

v1.3.0 → v2.0.0-beta.12022-07-10

PHP version history (3 changes)v1.0.0PHP ^7.0

v1.2.0PHP ^7.3 || ^8.0

v1.3.0PHP ^7.4 || ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/5ebe908b4fe73807ecdd9f88733342199c9991b7de800329f5b2b787c8210d62?d=identicon)[MGatner](/maintainers/MGatner)

---

Top Contributors

[![MGatner](https://avatars.githubusercontent.com/u/17572847?v=4)](https://github.com/MGatner "MGatner (89 commits)")[![jozefrebjak](https://avatars.githubusercontent.com/u/36922215?v=4)](https://github.com/jozefrebjak "jozefrebjak (2 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")[![kgrruz](https://avatars.githubusercontent.com/u/17552267?v=4)](https://github.com/kgrruz "kgrruz (1 commits)")

---

Tags

codeigniteranalyticscodeigniter4visitstraffic

### Embed Badge

![Health badge](/badges/tatter-visits/health.svg)

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

###  Alternatives

[codeigniter4/settings

Settings library for CodeIgniter 4

95589.6k34](/packages/codeigniter4-settings)[codeigniter4/tasks

Task Scheduler for CodeIgniter 4

124177.3k1](/packages/codeigniter4-tasks)[codeigniter4/devkit

Development toolkit for CodeIgniter libraries and projects

69201.9k121](/packages/codeigniter4-devkit)[tatter/alerts

Lightweight user alerts for CodeIgniter 4

4080.9k6](/packages/tatter-alerts)[tatter/patches

Automated project updates for CodeIgniter 4

3692.9k3](/packages/tatter-patches)[michalsn/minifier

Assets minification and versioning library for CodeIgniter 4.

5638.0k](/packages/michalsn-minifier)

PHPackages © 2026

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