定制 miniframe/statistics 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

miniframe/statistics

Composer 安装命令:

composer require miniframe/statistics

包简介

Website statistics addon for the Miniframe PHP Framework.

README 文档

README

This package adds website statistics to the Miniframe PHP Framework.

build code coverage

How to use

  1. In your existing project, type: composer require miniframe/statistics
  2. Add the directive below to your config.ini
  3. Run the task php public/index.php _STATISTICS update to update geoip and browscap databases
  4. Visit yourwebsite/_STATISTICS for output

Example config.ini directives

[framework]
middleware[] = Miniframe\Statistics\Middleware\Statistics

[statistics]
browscap_database_path = cache/browscap
storage_path = cache/

It's recommended to run the update task on a regular base.

How to enable GeoIP (country lookup)

For GeoIP, I use a local database so the IP address is not shared with any 3rd party. To get this database, a few steps are required;

  1. Add in your configuration ini:
    [statistics]
    geoip_database_path = cache/geoip
    
  2. Type composer require geoip2/geoip2:~2.0
  3. Create an account at https://dev.maxmind.com/geoip/geolite2-free-geolocation-data
  4. When you have an account, create a new license key at https://www.maxmind.com/en/accounts/613599/license-key and check no for the update tool.
  5. Copy the License Key and put them in a secrets.ini:
    [statistics]
    geoip_licensekey = ****************
    

    It's also recommended to put the secrets.ini in your .gitignore file so it won't end up in a git repository.

  6. Run the task php public/index.php _STATISTICS update to update the geoip database.

You can also install a tool to automatically download the databases.

How to password protect your statistics

For password protection, you can use the Basic HTTP Authentication middleware. For more about that, see the middlewares documentation.

How to change the URL for statistics

You can modify the URL for the statistics page by altering the slug:

[statistics]
slug = stats

GDPR compliance

First, let me state this is not covered by a lawyer, no garantees here.
I wrote this library to try to be fully complaint with the GDPR. As far as my knowledge goes, no personal data is stored.

I only store some global data like a country code, operating system and browser version, and don't even link between those data sets since there is no real need for that.

All data actually used can be seen in src/Model/PageHit.php

For Windows Developers

In the bin folder, a few batch files exist, to make development easier.

If you install Docker Desktop for Windows, you can use bin\composer.bat, bin\phpcs.bat, bin\phpunit.bat, bin\phpstan.bat and bin\security-checker.bat as shortcuts for Composer, CodeSniffer, PHPUnit, PHPStan and the Security Checker, without the need of installing PHP and other dependencies on your machine.

The same Docker container and tools are used in Bitbucket Pipelines to automatically test this project.

统计信息

  • 总下载量: 143
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: CC-BY-SA-4.0
  • 更新时间: 2021-09-25

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固