Skip to content

Latest commit

 

History

History
144 lines (94 loc) · 3.68 KB

3_installation.md

File metadata and controls

144 lines (94 loc) · 3.68 KB

Installation

To get started with Laravel Visits, use Composer to add the package to your project's dependencies:

composer require awssat/laravel-visits

Configurations

To adjust the package to your needs, you can publish the config file config/visits.php to your project's config folder using:

php artisan vendor:publish --provider="Awssat\Visits\VisitsServiceProvider" --tag=config

Redis Configuration

If you are not using Redis as your default data engine, skip this.

By default laravel-visits doesn't use the default laravel redis configuration (see issue #5)

To prevent any data loss add a new connection in config/database.php

'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)
],

and you can define your redis connection name in config/visits.php

'connection' => 'laravel-visits'

Eloquent (database) configuration

If you are using Redis as your default data engine, skip this.

Publish migration file, then migrate

php artisan vendor:publish --provider="Awssat\Visits\VisitsServiceProvider" --tag=migrations
php artisan migrate

Package Configuration

Laravel Visits can be configured to act the way you like, config/visits.php is clear and easy to understand but here some explanation for its settings.

config/visits.php settings explained

engine

'engine' => \Awssat\Visits\DataEngines\RedisEngine::class,

Suported data engines are \Awssat\Visits\DataEngines\RedisEngine::class, and \Awssat\Visits\DataEngines\EloquentEngine::class currently. If you use \Awssat\Visits\DataEngines\EloquentEngine::class then data will be stored in the default database (MySQL, SQLite or the one you are using)

connection

'connection' => 'laravel-visits',

Currently only applies when using Redis as data engine. Check Redis Configuration

periods

'periods' => [
    'day',
    'week',
    'month',
    'year',
],

By default, Visits of day, week, month, and year are recorded. But you can add or remove any of them as you like.

Note supported periods can be found in periods-options

You can add periods to global_ignore setting to skip recording any of these periods.

keys_prefix

'keys_prefix' =>  'visits',

A word that's appended to the begining of keys names. If you are using shared Redis database, it's important to keep this filled.

remember_ip

'remember_ip' => 15 * 60, // seconds

Every distinct IP will only be recorded as one visit every 15 min (default).

always_fresh

'always_fresh' => false,

If you set this to true, then any Visits Lists won't be cached any will return a new generated list.

We don't recommend enabling this feature as it's not good for performance.

ignore_crawlers

'ignore_crawlers' => true,

By default, visits from search engines bots and any other recognizable bots are not recorded. By enabling this you allow visits from bots to be recoded.

global_ignore

'global_ignore' => [],

By default, 'country', 'refer', 'periods', 'operatingSystem', and 'language' of a visitor are recoded. You can disable recoding any of them by adding them to the list.


Prev: < Requirements

Next: Quick start >