1. Go to this page and download the library: Download pianosolo/counter-bundle library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
pianosolo / counter-bundle example snippets
// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
// ...
new PianoSolo\CounterBundle\PianoSoloCounterBundle(),
);
}
namespace MyBundle\Entity;
use PianoSolo\Traits\CounterTrait;
class MyEntity
{
use CounterTrait;
//...
}
$myEntity = new MyEntity();
$entityManager->persist($myEntity);
$entityManager->flush();
namespace MyBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
class DefaultController extends Controller
{
public function showEntityAction()
{
//...
$myEntity = $myEntityRepository->findOneBy(array('id' => $id));
$myEntity->getCounter()->addClick(5); // Default value of parameter is 1
$entityManager->persist($myEntity);
$entityManager->flush();
}
}