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

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

dericktan/counter
=================

Hit counter for your pages.

v7.0.1(5y ago)08MITPHPPHP &gt;=7.2

Since Jul 18Pushed 5y agoCompare

[ Source](https://github.com/Dericktan/Counter)[ Packagist](https://packagist.org/packages/dericktan/counter)[ RSS](/packages/dericktan-counter/feed)WikiDiscussions master Synced 6d ago

READMEChangelog (2)Dependencies (4)Versions (22)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

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 57.9% 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 ~102 days

Recently: every ~64 days

Total

19

Last Release

2123d ago

Major Versions

5.2.9.2 → 6.0.02019-11-12

6.0.2 → 7.02020-07-25

PHP version history (3 changes)5.1PHP &gt;=5.3.3

7.0PHP &gt;=7.3

v7.0.1PHP &gt;=7.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/85b53db71dea77c753d281f6b9a5f1c9984c0ceeaf56d3c1150ee2aee7efd327?d=identicon)[Dericktan](/maintainers/Dericktan)

---

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 (3 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)")[![Dericktan](https://avatars.githubusercontent.com/u/16285179?v=4)](https://github.com/Dericktan "Dericktan (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)")[![oprypkhantc](https://avatars.githubusercontent.com/u/54406427?v=4)](https://github.com/oprypkhantc "oprypkhantc (1 commits)")

### Embed Badge

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

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

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M687](/packages/barryvdh-laravel-ide-helper)[orchestra/canvas

Code Generators for Laravel Applications and Packages

21017.2M158](/packages/orchestra-canvas)[shlinkio/shlink

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

4.8k4.3k](/packages/shlinkio-shlink)[kirschbaum-development/commentions

A package to allow you to create comments, tag users and more

12369.2k](/packages/kirschbaum-development-commentions)[tehwave/laravel-achievements

Simple, elegant Achievements the Laravel way

7012.8k](/packages/tehwave-laravel-achievements)[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)
