PHPackages                             kwxs/counter - 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. kwxs/counter

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

kwxs/counter
============

Hit counter for your pages.

6.0.2(6y ago)0272MITPHPPHP &gt;=5.3.3

Since Jul 18Pushed 6y agoCompare

[ Source](https://github.com/KWXS/Counter)[ Packagist](https://packagist.org/packages/kwxs/counter)[ RSS](/packages/kwxs-counter/feed)WikiDiscussions master Synced today

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

Hit Counter for Laravel 5.\*
----------------------------

[](#hit-counter-for-laravel-5)

#### Installation

[](#installation)

Run the following command:

```
composer require kryptonit3/counter:5.2.*
```

Add the following to your `config\app.php` Service Providers

```
Kryptonit3\Counter\CounterServiceProvider::class,
```

Add the following to your `config\app.php` Facades

```
'Counter' => Kryptonit3\Counter\Facades\CounterFacade::class,
```

Then run the following:

```
php artisan vendor:publish --provider="Kryptonit3\Counter\CounterServiceProvider" --tag="migrations"

php artisan migrate
```

Set Cookie Name in Laravel env Config file

```
    COUNTER_COOKIE="Name of your cookie"
```

### How to Use

[](#how-to-use)

#### Regular pages

[](#regular-pages)

Just add `Counter::showAndCount('home')` ( for blades uses `{{ Counter::showAndCount('home') }}` ). Change `home` to a unique name for the page you are working with.

#### Dynamic pages

[](#dynamic-pages)

For dynamic pages, such as user profiles, or job listings etc you may provide a dynamic element like this `Counter::showAndCount('user-profile', $user->id)` ( for blades use `{{ Counter::showAndCount('user-profile', $user->id) }}` )

> Change `user-profile` to a unique name for the page you are working with.

Number output is already formatted. So 3000 visitors will render as 3,000

If you have records on a page but do not want to count visiting the page displaying the records as a hit on the record itself then change `showAndCount` to just `show`. Example `Counter::show('job-listings', $job->id)` ( for blades use `{{ Counter::show('job-listings', $job->id) }}` )

You may get all hits for every page on the entire site with `Counter::allHits()` ( for blades use `{{ Counter::allHits() }}` ). To specify a day constraint, like only all hits for the past 30 days then do `Counter::allHits(30)` (for blades use `{{ Counter::allHits(30) }}` ).

If you would just like to process a hit for a page without displaying anything then just use `Counter::count('user-profile', $user->id)`. Works the same as all previous examples for both static and dynamic pages, blade is the same syntax. Useful for counting hits for a page without letting everyone see.

Enjoy!

### Extra

[](#extra)

- Package influenced by: [defuse/phpcount](https://github.com/defuse/phpcount "defuse/phpcount")
- How this differs from: [weboAp/Visitor](https://github.com/weboAp/Visitor "weboAp/Visitor")

This package lets you see hit counts for specific pages/objects as well as an overall site hit count. It also uses a uniquely generated cookie (fallback to IP) to give a more accurate reading. Nice package for the pro-anonymous people :)

```
mysql> select * from kryptonit3_counter_page;
+----+--------------------------------------+
| id | page                                 |
+----+--------------------------------------+
|  2 | 24d83c12-a1e0-598b-93ee-df05ae3f87e7 |
|  1 | 597e0526-152f-5fc0-9d44-b51fd9e45b8f |
+----+--------------------------------------+
2 rows in set (0.00 sec)

mysql> select * from kryptonit3_counter_visitor;
+----+------------------------------------------------------------------+
| id | visitor                                                          |
+----+------------------------------------------------------------------+
|  1 | 88a5f67524a1bc75da5ea8b7250e8280c78d60dce59b129dc37123b137ce6199 |
+----+------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> select * from kryptonit3_counter_page_visitor;
+---------+------------+---------------------+
| page_id | visitor_id | created_at          |
+---------+------------+---------------------+
|       1 |          1 | 2015-06-22 17:52:43 |
|       2 |          1 | 2015-06-22 17:52:43 |
+---------+------------+---------------------+
2 rows in set (0.00 sec)
```

Pull requests are welcome.
--------------------------

[](#pull-requests-are-welcome)

###  Health Score

31

—

LowBetter than 66% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 61.1% 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 ~98 days

Recently: every ~155 days

Total

17

Last Release

2425d ago

Major Versions

5.2.9.2 → 6.0.02019-11-12

### Community

Maintainers

![](https://www.gravatar.com/avatar/413b481f92caa1d96de546c0417395b0ca178658d9f6ef195ae303a91d2765e5?d=identicon)[ivankolodii](/maintainers/ivankolodii)

![](https://www.gravatar.com/avatar/f8e4d651b6994a06b201654d8f7835be0dead96022dd195e013e0bac9cf46e9b?d=identicon)[chris-kwx](/maintainers/chris-kwx)

---

Top Contributors

[![Kryptonit3](https://avatars.githubusercontent.com/u/72818445?v=4)](https://github.com/Kryptonit3 "Kryptonit3 (22 commits)")[![ivankolodii](https://avatars.githubusercontent.com/u/35073476?v=4)](https://github.com/ivankolodii "ivankolodii (4 commits)")[![akhrystonko](https://avatars.githubusercontent.com/u/35073687?v=4)](https://github.com/akhrystonko "akhrystonko (3 commits)")[![Reflow1319](https://avatars.githubusercontent.com/u/6665500?v=4)](https://github.com/Reflow1319 "Reflow1319 (2 commits)")[![ahxar](https://avatars.githubusercontent.com/u/2148793?v=4)](https://github.com/ahxar "ahxar (2 commits)")[![vitivs](https://avatars.githubusercontent.com/u/2463017?v=4)](https://github.com/vitivs "vitivs (1 commits)")[![johnhout](https://avatars.githubusercontent.com/u/1277118?v=4)](https://github.com/johnhout "johnhout (1 commits)")[![kanasite](https://avatars.githubusercontent.com/u/985129?v=4)](https://github.com/kanasite "kanasite (1 commits)")

### Embed Badge

![Health badge](/badges/kwxs-counter/health.svg)

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

###  Alternatives

[laravel/horizon

Dashboard and code-driven configuration for Laravel queues.

4.2k95.4M305](/packages/laravel-horizon)[illuminate/queue

The Illuminate Queue package.

21332.6M1.6k](/packages/illuminate-queue)[shlinkio/shlink

A self-hosted and PHP-based URL shortener application with CLI and REST interfaces

5.1k5.2k](/packages/shlinkio-shlink)[directorytree/ldaprecord-laravel

LDAP Authentication &amp; Management for Laravel.

5752.3M18](/packages/directorytree-ldaprecord-laravel)[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)

PHPackages © 2026

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