Download the PHP package coderflexx/laravisit without Composer

On this page you can find all versions of the php package coderflexx/laravisit. 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 laravisit



The Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

A clean way to track your pages & understand your user's behavior

Installation

You can install the package via composer:

You can publish the config file with:

then, run database migration

This is the contents of the published config file:

Usage

Use HasVisits Trait

The first thing you need to do is, to use HasVisits trait, and implement CanVisit interface.

After this step, you are all set, you can now count visits by using visit method

You can chain methods to the visit method. Here are a list of the available methods:

METHOD SYNTAX DESCRIPTION EXAMPLE
withIp() string $ip = null Set an Ip address (default request()->ip()) $post->visit()->withIp()
withSession() string $session = null Set an Session ID (default session()->getId()) $post->visit()->withSession()
withData() array $data Set custom data $post->visit()->withData(['region' => 'USA'])
withUser() Model $user = null Set a user model (default auth()->user()) $user->visit()->withUser()

By default, you will have unique visits each day using dailyInterval() method. Meaning, when the users access the page multiple times in a day time frame, you will see just one record related to them.

If you want to log users access to a page with different timeframes, here are a bunch of useful methods:

METHOD SYNTAX DESCRIPTION EXAMPLE
hourlyInterval() void Log visits each hour $post->visit()->hourlyIntervals()->withIp();
dailyInterval() void Log visits each day $post->visit()->dailyIntervals()->withIp();
weeklyInterval() void Log visits each week $post->visit()->weeklyIntervals()->withIp();
monthlyInterval() void Log visits each month $post->visit()->monthlyIntervals()->withIp();
yearlyInterval() void Log visits each year $post->visit()->yearlyIntervals()->withIp();
customInterval() mixed $interval Log visits within a custom interval $post->visit()->customInterval( now()->subYear() )->withIp();

Get The Records With Popular Time Frames

After the visits get logged, you can retrieve the data by the following method:

METHOD SYNTAX DESCRIPTION EXAMPLE
withTotalVisitCount() void get total visit count Post::withTotalVisitCount()->first()->visit_count_total
popularAllTime() void get popular visits all time Post::popularAllTime()->get()
popularToday() void get popular visits in the current day Post::popularToday()->get()
popularLastDays() int $days get popular visits last given days Post::popularLastDays(10)->get()
popularThisWeek() void get popular visits this week Post::popularThisWeek()->get()
popularLastWeek() void get popular visits last week Post::popularLastWeek()->get()
popularThisMonth() void get popular visits this month Post::popularThisMonth()->get()
popularLastMonth() void get popular visits last month Post::popularLastMonth()->get()
popularThisYear() void get popular visits this year Post::popularThisYear()->get()
popularLastYear() void get popular visits last year Post::popularLastYear()->get()
popularBetween() Carbon $from, Carbon $to get popular visits between custom two dates Post::popularBetween(Carbon::createFromDate(2019, 1, 9), Carbon::createFromDat(2022, 1, 3))->get();

Visit Presenter

This package is coming with helpful decorate model properties, and it uses Laravel Presenter package under the hood.

METHOD SYNTAX DESCRIPTION EXAMPLE
ip() void Get the associated IP from the model instance $post->visits->first()->present()->ip
user() void Get the associated User from the model instance $post->visits->first()->present()->user->name

Testing

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Inspiration

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of laravisit with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
coderflexx/laravel-presenter Version ^2.0
illuminate/contracts Version ^10.0|^11.0
jaybizzle/crawler-detect Version ^1.2
spatie/laravel-package-tools Version ^1.9.2
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 coderflexx/laravisit contains the following files

Loading the files please wait ....