PHPackages                             xsuchy09/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. [Database &amp; ORM](/categories/database)
4. /
5. xsuchy09/visitor

ActiveLibrary[Database &amp; ORM](/categories/database)

xsuchy09/visitor
================

Visitor saves info about visitors of web page into DB and using cookies to identify them.

1.0.4(6y ago)122Apache-2.0PHPPHP &gt;=7.1

Since Apr 29Pushed 6y ago1 watchersCompare

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

READMEChangelogDependencies (2)Versions (5)Used By (0)

Visitor
=======

[](#visitor)

PHP library to save info about visitors of web page into DB. PHP 7.1 is required.

Authors:

- Petr Suchy (xsuchy09 - [www.wamos.cz](http://www.wamos.cz))

Overview
--------

[](#overview)

Visitor saves info about visitor of web page into db and uses cookie to identify same visitor. Lifetime of that cookie is configurable - default is 10 years. It is using [UtmCookie](https://github.com/xsuchy09/utm-cookie) to save UTMs too and [Hashids](https://github.com/ivanakimov/hashids.php) to get unique hash for every single visitor (for example in JavaScript it is not safe to use directly ID from DB).

SQL to create DB table is included (visitor.sql - for PostgreSQL). Column "visits\_count" is counted with trigger (new visit is counted if it is more than 24 hours from last visit). You can change it as you want.

Installation (via composer)
---------------------------

[](#installation-via-composer)

[Get composer](http://getcomposer.org/doc/00-intro.md) and add this in your requires section of the composer.json:

```
{
    "require": {
        "xsuchy09/visitor": "*"
    }
}

```

and then

```
composer install

```

Usage
-----

[](#usage)

### Basic Example

[](#basic-example)

```
$pdo = $PDO = new PDO(sprintf('pgsql:host=%s;port=%d;dbname=%s;user=%s;password=%s', 'localhost', 5432, 'db_name', 'username', 'password'));
$visitor = new Visitor($pdo, 'HashidsKey'); // it needs pdo instance in constructor and key for Hashids (use your own for your security). You can use others optionally params as you need.
$visitor->addVisit(); // set last visit of of visitor if he is identified or just create the new one with first visit
```

More examples can be found in the examples/ directory. Since version 1.0.4 you can set cookie params in constructor (path, domain, secure, httpOnly, sameSite) and some getters were added.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

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

Total

4

Last Release

2298d ago

### Community

Maintainers

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

---

Top Contributors

[![xsuchy09](https://avatars.githubusercontent.com/u/1107359?v=4)](https://github.com/xsuchy09 "xsuchy09 (12 commits)")

---

Tags

visitoranalytics

### Embed Badge

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

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

PHPackages © 2026

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