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

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

kryptonit3/counter
==================

Hit counter for your pages.

5.2.11(5y ago)8724.1k33[14 issues](https://github.com/Kryptonit3/Counter/issues)MITPHPPHP &gt;=5.3.3

Since Jul 18Pushed 4y ago7 watchersCompare

[ Source](https://github.com/Kryptonit3/Counter)[ Packagist](https://packagist.org/packages/kryptonit3/counter)[ RSS](/packages/kryptonit3-counter/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (3)Versions (16)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

39

—

LowBetter than 86% of packages

Maintenance17

Infrequent updates — may be unmaintained

Popularity38

Limited adoption so far

Community22

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 72.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 ~143 days

Recently: every ~258 days

Total

14

Last Release

2091d ago

### Community

Maintainers

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

---

Top Contributors

[![Kryptonit3](https://avatars.githubusercontent.com/u/72818445?v=4)](https://github.com/Kryptonit3 "Kryptonit3 (24 commits)")[![Reflow1319](https://avatars.githubusercontent.com/u/6665500?v=4)](https://github.com/Reflow1319 "Reflow1319 (2 commits)")[![hemal-digiflux](https://avatars.githubusercontent.com/u/53688978?v=4)](https://github.com/hemal-digiflux "hemal-digiflux (2 commits)")[![ahxar](https://avatars.githubusercontent.com/u/2148793?v=4)](https://github.com/ahxar "ahxar (2 commits)")[![kanasite](https://avatars.githubusercontent.com/u/985129?v=4)](https://github.com/kanasite "kanasite (1 commits)")[![johnhout](https://avatars.githubusercontent.com/u/1277118?v=4)](https://github.com/johnhout "johnhout (1 commits)")[![vitivs](https://avatars.githubusercontent.com/u/2463017?v=4)](https://github.com/vitivs "vitivs (1 commits)")

### Embed Badge

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

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

###  Alternatives

[shetabit/visitor

Laravel visitor

565578.2k8](/packages/shetabit-visitor)[shlinkio/shlink

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

4.8k4.3k](/packages/shlinkio-shlink)[illuminate/pipeline

The Illuminate Pipeline package.

9346.6M213](/packages/illuminate-pipeline)[tehwave/laravel-achievements

Simple, elegant Achievements the Laravel way

7012.8k](/packages/tehwave-laravel-achievements)[interaction-design-foundation/laravel-geoip

Support for multiple Geographical Location services.

17221.0k3](/packages/interaction-design-foundation-laravel-geoip)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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