2017 © Pedro Peláez
 

symfony-bundle views-counter-bundle

Symfony document/entity views counter

image

cengizhancaliskan/views-counter-bundle

Symfony document/entity views counter

  • Tuesday, March 28, 2017
  • by cengizhan
  • Repository
  • 1 Watchers
  • 2 Stars
  • 153 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 5 % Grown

The README.md

ViewsCounter Bundle

ViewsCounter increments views counts for document/entity., (*1)

Setup the bundle

Step 1: Install ViewsCounterBundle

ViewsCounter bundle is installed using [Composer][1]., (*2)

composer require cengizhancaliskan/views-counter-bundle

Enable ViewsCounterBundle in your AppKernel:, (*3)

// app/AppKernel.php

public function registerBundles()
{
    $bundles = [
        // ...
        new Cengizhan\ViewsCounterBundle\CengizhanViewsCounterBundle(),
    ];

    // ...
}

Step 2: Configure your entity

``` php <?php, (*4)

namespace YourBundle\YourEntity;, (*5)

use Cengizhan\ViewsCounterBundle\Model\VisitableInterface; use Cengizhan\ViewsCounterBundle\Traits\VisitableEntityTrait; use Doctrine\ORM\Mapping as ORM;, (*6)

/** * @ORM\Entity() */ class Article implements VisitableInterface { use VisitableEntityTrait;, (*7)

/**
 * @ORM\Column(name="id", type="integer")
 * @ORM\Id
 * @ORM\GeneratedValue(strategy="IDENTITY")
 */
protected $id;

/**
 * @ORM\Column(name="title", type="string")
 */
protected $title;

public function getId()
{
    return $this->id;
}

public function setTitle($title)
{
    $this->title = $title;
}

public function getTitle()
{
    return $this->title;
}

}, (*8)

## Usage:

``` php
<?php

....
$this->get('views_counter.views_counter')->count($article);
....

How to configure, (*9)

If you can query builder ( recommendation for cached entity ), (*10)

# config.yml
....
cengizhan_views_counter:
    use_query_builder: true

The Versions

28/03 2017

dev-master

9999999-dev https://github.com/cengizhancaliskan/ViewsCounterBundle

Symfony document/entity views counter

  Sources   Download

MIT

The Requires

 

The Development Requires

view count views counter view counter entity views entity view counter

28/03 2017

v1.0.0

1.0.0.0 https://github.com/cengizhancaliskan/ViewsCounterBundle

Symfony document/entity views counter

  Sources   Download

MIT

The Requires

 

The Development Requires

view count views counter view counter entity views entity view counter