2017 © Pedro Peláez
 

yii2-extension yii2-count-user

Count views and users on site.

image

lugano/yii2-count-user

Count views and users on site.

  • Monday, June 13, 2016
  • by Lugano
  • Repository
  • 1 Watchers
  • 0 Stars
  • 16 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 33 % Grown

The README.md

yii2-count-user

Module of count of users for YII2 with report by email

Installation, (*1)

Extension may be installed by taking the following simple steps:, (*2)

  1. add "lugano/yii2-count-user": "*" to the require section of your composer.json file.
  2. run composer install to install the specified extensions.
  3. execute yii migrate --migrationPath=vendor/lugano/yii2-count-user/migrations

Usage, (*3)

Suppose, You have site with 4 pages. These pages has been displaying user using SiteController. This SiteController extends Controller from YII2, and has methods , called actionIndex, actionAdverbs, actionVerbs, actionDictionary., (*4)

Code below shows default YII2 controller for site., (*5)

SiteController extends Controller {, (*6)

public $hosts;, (*7)

public $views;, (*8)

public function actionIndex(){, (*9)

  self::countUser();
  return $this->render('index');

}, (*10)

public function actionAdverbs(){, (*11)

  self::countUser();
  return $this->render('adverbs');

}, (*12)

public function actionVerbs(){, (*13)

 self::countUser();
 return $this->render('verbs');

}, (*14)

public function actionDictionary(){, (*15)

  self::countUser();
  return $this->render('dictionary');

} }, (*16)

In order to count users and views your site you must do several action:, (*17)

1) Add use lugano\userCounter\controllers\DefaultController; in header file with your SiteController;, (*18)

2) Add method in you SiteController(your default controller);, (*19)

public function countUser()
{
        $settings = array(
                           'posmail' => 'xxxx@ukr.net',
                           'posname' => 'my-site.com',
                   'period' => '1...365'
                           );
        $temp = new DefaultController($settings);
        $report = $temp->counter();
        $this->views = $report['views'];
    $this->hosts = $report['hosts'];

}

3) Add two public properties $host and $views to your SiteController;, (*20)

4) Call self::countUser() in each your method actionIndex, actionAdverbs, actionVerbs, actionDictionary, (*21)

5) Add to your main.php file string like context->hosts .'   '.'Views: '. $this->context->views; ?>, (*22)

Describing for variable $setting of class "DefaultController", (*23)

'posmail' - email will be receiving report from site; 'posname' - name for sender(your site); 'period' - period between reports from you site(not less than 1 and not more than 365 days);, (*24)

The Versions

13/06 2016

dev-master

9999999-dev

Count views and users on site.

  Sources   Download

BSD-3-Clause

by Sergey Ponomarev

yii2 views users count

13/06 2016

1.0.1

1.0.1.0

Count views and users on site.

  Sources   Download

BSD-3-Clause

by Sergey Ponomarev

yii2 views users count