Website statistics addon for the Miniframe PHP Framework.
This package is auto-updated.
Last update: 2022-11-25 19:46:13 UTC
This package adds website statistics to the Miniframe PHP Framework.
How to use
- In your existing project, type:
composer require miniframe/statistics
- Add the directive below to your config.ini
- Run the task
php public/index.php _STATISTICS updateto update geoip and browscap databases
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;
- Add in your configuration ini:
[statistics] geoip_database_path = cache/geoip
composer require geoip2/geoip2:~2.0
- Create an account at https://dev.maxmind.com/geoip/geolite2-free-geolocation-data
- 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.
- Copy the
License Keyand put them in a
[statistics] geoip_licensekey = ****************
It's also recommended to put the
.gitignorefile so it won't end up in a git repository.
- Run the task
php public/index.php _STATISTICS updateto update the geoip database.
You can also install a tool to automatically download the databases.
How to password protect your statistics
How to change the URL for statistics
You can modify the URL for the statistics page by altering the slug:
[statistics] slug = stats
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
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.