Download the PHP package krowek/view-counter-bundle without Composer

On this page you can find all versions of the php package krowek/view-counter-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package view-counter-bundle

The View Counter Bundle

Welcome to the "TchoulomViewCounterBundle".

This bundle is used to count the number of views of a web page (the viewership).

This bundle can also be used to draw a graphical representation of statistical data of the web pages.

Monthly views in 2018

Table of contents

Features include

- Viewcounter
- Statistics
- Geolocation

Documentation

The ViewCounter documentation

Installation

Step 1: Download TchoulomViewCounterBundle using composer

You can install it via Composer:

or

or

Check that it is recorded in the composer.json file

Step 2: Enable the Bundle

Edit the appKernel.php file

Usage

Step 1: Interface and Property

Suppose that you have an Article Entity.

This Entity must implement the ViewCountable interface:

Add the $views property and the target Entity ViewCounter.

The $views property allows to get the number of views:

Step 2: ViewCounter

The ViewCounter Entity allows to set the IP address, the view_date, and the article_id.

The ViewCounter Entity must extend the BaseViewCounter:

Update the doctrine relationship between the ViewCounter Entity and your Article Entity:

Step 3: Configuration

For symfony 4 or 5:
For version of symfony less than 4:
viewcounter configuration:

The "view_counter"

The different values of view_strategy are : daily_view, unique_view, increment_each_view, hourly_view, weekly_view, monthly_view, yearly_view, view_per_minute, view_per_second.

The "statistics"

The use_stats allows to indicate if you want to use statistics.

If use_stats is set to true, statistics functionality will be used (confers the Step 6).

The stats_file_name allows to define the name of the statistics file.

The default name of stats_file_name is stats

The stats_file_extension allows to define the extension of the statistics file.

Example :

If stats_file_extension: txt, then the default name of the statistics file will be stats.txt

If stats_file_extension:, then the default name of the statistics file will be stats

The full path of the statistics file is var/viewcounter of your project.

The "geolocation"

The Geolocation defines a service which will allow you to geolocate page visits.

The geolocator_id corresponds to the identifier or the name of the class of your geolocation service, depending on the version of symfony used:

or

if your service is declared as such:

You must then set up your "Geolocator" service as we will see in this documentation Step 6: The Geolocation.

You must comment on the geolocation configuration if you do not want to use it in your project:

Step 4: The Controller

2 methods are available:

Method 1

Method 2

You only need to save your Article Entity via the 'tchoulom.viewcounter' service:

The second method returns the current page ($article).

You can choose the method that is most appropriate for your situation.

Step 5: The View

Finally you can display the number of views:

Step 6: The Geolocation

Some bundles can be used to have a geolocation system in your project. These bundles usually use the ip address in order to geolocate the visitor of the web page.

For the purposes of this documentation, we will use this bundle, for example:

gpslab/geoip2 : https://github.com/gpslab/geoip2

You can read the documentation for installing and using this bundle if you want to use it.

Otherwise, you can use another geolocation bundle according to your preferences.

Create the "Geolocator" service that will allow you to manage geolocation data

Your Geolocation service must implement the "Tchoulom\ViewCounterBundle\Adapter\Geolocator\GeolocatorInterface" interface.

you are free to improve the above "Geolocator" service, in particular to verify the existence of geolocation data.

You can go to this step for the use of geolocation data Search for geolocation data.

Step 7: Exploitation of statistical data

Trick

For Symfony 4 or 5, inject the service you want to use, instead of going through the container: $this->get('tchoulom.viewcounter.stats_finder');

The StatsFinder service

Use the StatsFinder service to get statistics of a web page :

You can also get statistical data of a web page by year, month, week, day, hour, minute and second

Get the yearly statistics

Result:

In 2019, there were 98537215 views.

In 2018, there were 95548144 views.

In 2017, there were 47882376 views.

Get the monthly statistics

Result:

In the month of August (month number 8) 2019, there were 951224 views.

In the month of July (month number 7) 2019, there were 921548 views.

In the month of June (month number 6) 2019, there were 845479 views.

Get the weekly statistics

Result:

In the week number 34 in august (month number 8) 2019, there were 494214 views.

In the week number 33 in august 2019, there were 117649 views.

In the week number 32 in august 2019, there were 183254 views.

Get the daily statistics

Result:

On Monday of the week number 33 in august (month number 8) 2019, there were 16810 views.

On Tuesday of the week number 33 in august 2019, there were 16804 views.

On Wednesday of the week number 33 in august 2019, there were 16807 views.

...

Get the hourly statistics

Result:

On Thursday of the week number 33 of August (month number 8) 2019:

Get the statistics per minute

Result:

On Saturday of the week number 33 of August (month number 8) 2019 at 15h ('h15') :

Get the statistics per second

Result:

On Saturday of the week number 33 of August (month number 8) 2019 at 15H49:

The data in the stats file represents the view statistics, as shown in the following figure:

Statistical data in 2018

The figure above shows that the statistical data contain 2 "viewcountable" entities: article and news.

The statistical data of the entity article are recorded over 12 months.

Let's zoom in on the statistics for the first week of January:

the statistical data of the first week of January 2018

Search for geolocation data

The geolocation data of visitors to your web pages may look like the following figure:

the geolocation data

The figure above shows that visitors have viewed the web page (with the identifier 3) from 4 countries: United States, France, United Kingdom and Ireland.

Let's zoom in on the country "United States" in order to visualize the geolocation data it contains:

the geolocation data washington

There are 5 views from the United States including 4 in the town of Washington located in the District of Columbia region.

These 5 views are spread over 2 regions: District of Columbia and New York.

View date data can also be used:

the geolocation view date
Gets country stats

Result:

Gets region stats

Result:

Gets city stats

Result:

Gets stats by country

Result:

Gets stats by region

Result:

Gets stats by city

Result:

The StatsFinder service provides other functions that you can browse.

Build a graph with "Google Charts"

You can now use these statistical data to build a graph, as shown in the following figure:

Statistics of monthly views in 2018

Monthly views in 2018

Also, you can build the graph on statistics of daily view, hourly view, weekly view and yearly view according to the data in the statistics file.

You can find out about "Google Charts" here

The StatsComputer service

Use the StatsComputer service to calculate the min value, max value, average value, range value, mode value, median value and the number of occurrences of the statistics :

First of all, get the stats computer service

The functions of the statsComputer service can take as argument the $yearlyStats, $monthlyStats, $weeklyStats, $daylyStats, $hourlyStats, $statsPerMinute, and $statsPerSecond

Calculates the min value

Result:

Calculates the max value

Result:

Calculates the average

The average is the sum of the values ​​of the statistical series divided by the number of values.

Result:

Calculates the range

The range is the difference between the highest number and the lowest number.

Result:

Calculates the mode

The mode is the number that is in the array the most times.

Result:

Calculates the median

The median is the middle value after the numbers are sorted smallest to largest.

Result:

Count the number of values ​​in the statistical series

Result:

Tools

Command

Cleanup viewcounter data

You can delete the viewcounter data using the ViewcounterCleanupCommand command:

Original Credits

Created by Ernest TCHOULOM for tchoulom.com.

License

This bundle is released under the MIT license. See the complete license in the bundle:

Enjoy!

Need help or found a bug? http://www.tchoulom.com


All versions of view-counter-bundle with dependencies

PHP Build Version
Package Version
Requires php Version >=7.2.5
symfony/framework-bundle Version ^2.7 || ^3.0 || ^4.0 || ^5.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package krowek/view-counter-bundle contains the following files

Loading the files please wait ....