PHP code example of foothing / laravel-simple-pageviews
1. Go to this page and download the library: Download foothing/laravel-simple-pageviews library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
foothing / laravel-simple-pageviews example snippets
// Enable or disable tracking.
"enabled" => true,
// Add patterns to be blacklisted (ignored and not tracked).
// These patterns will apply if the UrlWhitelist rule is
// enabled in the chain.
"blacklist" => [
// i.e. '/^(admin|api|auth).*/'
],
// Rules chain.
"rules" => [
"Foothing\Laravel\Visits\Rules\Crawler",
"Foothing\Laravel\Visits\Rules\UrlWhitelist",
],
$manager = app()->make("Foothing\Laravel\Visits\Reports\ReportManager");
// Get visits with url and hits. This should be used to
// get an overview of the best performer urls.
$manager->getVisits();
[
{
"url": "foo/bar",
"hits": 129
},
{
"url": "baz",
"hits": 40
}
]
// Return int
$manager->countOverallVisits();
$manager->countOverallVisits('today', 'tomorrow', 'foo/bar');
// Return int
$manager->countUniqueVisits('currentWeek');
$manager->countUniqueVisits('currentWeek', null, 'foo/bar');
// Return a data collection meant for chart plotting.
$manager->getVisitsTrendDaily();
[
{
"day": "2016-10-08"
"hits": 129
},
{
"day": "2016-10-09"
"hits": 40
}
]
// Triggers default filter
$manager->getVisits();
// String presets
$manager->getVisits('today');
$manager->getVisits('currentWeek');
$manager->getVisits('currentMonth');
$manager->getVisits('currentYear');
// Single day
$manager->getVisits(\Carbon::now());
// Period
$manager->getVisits(\Carbon::now(), Carbon::tomorrow());
/**
* The Artisan commands provided by your application.
*
* @var array
*/
protected $commands = [
'Foothing\Laravel\Visits\Commands\DumpVisitsBuffer',
];
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
// Adjust this with your needs.
$schedule->command('visits:buffer')->dailyAt("00:00");
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.