laravel擴(kuò)展包統(tǒng)計(jì)頁(yè)面訪問次數(shù)——awssat/laravel-visits,用于統(tǒng)計(jì)在每個(gè)頁(yè)面的訪問次數(shù),通過判斷IP來實(shí)現(xiàn)通過訪問次數(shù)的功能。
項(xiàng)目地址:https://github.com/awssat/laravel-visits
安裝命令:
composer require awssat/laravel-visits
安裝成功之后將配置文件發(fā)布出來:
php artisan vendor:publish --provider="awssat\Visits\VisitsServiceProvider"
會(huì)生成配置文件config/visits.php
為了提高統(tǒng)計(jì)的性能,我們需要進(jìn)行額外的配置
在config/database.php中redis選項(xiàng)增加以下內(nèi)容:
'laravel-visits' => [
'host' => env('REDIS_HOST', '127.0.0.1'),
'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', 6379),
'database' => 3, // anything from 1 to 15, except 0 (or what is set in default)
],
完整的代碼如下:
'redis' => [
'client' => 'predis',
'default' => [
'host' => env('REDIS_HOST', '127.0.0.1'),
'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', 6379),
'database' => 0,
],
'laravel-visits' => [
'host' => env('REDIS_HOST', '127.0.0.1'),
'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', 6379),
'database' => 3, // anything from 1 to 15, except 0 (or what is set in default)
],
],