PHPackages                             exa2040/laravel-view-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. exa2040/laravel-view-counter

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

exa2040/laravel-view-counter
============================

A view and like counter extension for your laravel project.

017PHP

Since Jan 26Pushed 9y ago1 watchersCompare

[ Source](https://github.com/ExA2040/laravel-view-counter)[ Packagist](https://packagist.org/packages/exa2040/laravel-view-counter)[ RSS](/packages/exa2040-laravel-view-counter/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Laravel ViewCounter
===================

[](#laravel-viewcounter)

A view and like counter extension for your laravel project. It uses session storage if the user is not logged in and keeps it clean while the session is active (no double likes or views). If a user is logged in, the information about hthe likes and views are stored into the database for getting history.

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

[](#installation)

Install using composer:

```
composer require exa2040/view-counter
```

While the package is not stable, please make sure you added it as dev: Open "composer.json" manually and add "fraank/view-counter": "dev-master" into require.

Add the service provider in `app/config/app.php`:

```
ExA2040\LaravelViewCounter\ViewCounterServiceProvider::class,
```

The service provider will register an interface for your models to use view\_counter and like\_couter functionality.

To create the basic tables you have to provide the migation files:

```
php artisan vendor:publish
```

Now you can migrate:

```
php artisan migrate
```

Now you can register the like and view functionality in your model:

```
class Object extends Eloquent {
  use ExA2040\LaravelViewCounter\ViewCounterTrait;
}
```

You can call the actions for like and unlike in your views (or controllers) like this:

```
{{ route('view_counter.like', array('class_name' => 'post', 'object_id' => $post->id)) }}
{{ route('view_counter.unlike', array('class_name' => 'post', 'object_id' => $post->id)) }}
```

Examples
--------

[](#examples)

### Basic Usage

[](#basic-usage)

\*\*Increment a ViewCounter in a Controller (show action)

```
$object->view();
```

\*\*Get count of Views

```
$object->views_count();
```

\*\*Did the user viewed the object?

```
$object->isViewed();
```

\*\*Increment the LikeCounter in a Controller (show action)

```
$object->like();
```

\*\*Unlike

```
$object->unlike();
```

\*\*Get count of Likes

```
$object->likes_count();
```

\*\*Did the user liked the object?

```
$object->isLiked();
```

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/398ebcaea3b9d3f6edfa787af9a7ef21afbffc3084d9dbe9d3d08e78f6e67af1?d=identicon)[ExA2040](/maintainers/ExA2040)

---

Top Contributors

[![akaseiryu](https://avatars.githubusercontent.com/u/196625032?v=4)](https://github.com/akaseiryu "akaseiryu (9 commits)")

### Embed Badge

![Health badge](/badges/exa2040-laravel-view-counter/health.svg)

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

###  Alternatives

[jms/composer-deps-analyzer

Builds a Dependency Graph from a composer.json file

60270.2k3](/packages/jms-composer-deps-analyzer)[cristal/pptx

PHP library for manipulating PowerPoint (PPTX) files

2757.2k](/packages/cristal-pptx)[mpstenson/laravel-advanced-string

This application provides advanced string functions beyond what Laravel itself provides.

725.7k](/packages/mpstenson-laravel-advanced-string)

PHPackages © 2026

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