PHP code example of rvxlab / laravel-analytics

1. Go to this page and download the library: Download rvxlab/laravel-analytics 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/ */

    

rvxlab / laravel-analytics example snippets


use Illuminate\Foundation\Application;
use Illuminate\Foundation\Configuration\Middleware;
use RVxLab\Analytics\Middleware\RecordPageView;

return Application::configure(basePath: dirname(__DIR__))
    ->withMiddleware(function (Middleware $middleware) {
        $middleware->append([RecordPageView::class]);
        // OR
        $middleware->appendToGroup('<middlewareGroup>', [RecordPageView::class]);
    })->create();

namespace App\Http;

use RVxLab\Analytics\Middleware\RecordPageView;

class Kernel 
{
    protected $middleware = [
        // --snip--
        RecordPageView::class,
    ];

    protected $middlewareGroups = [
        'web' => [
            // --snip--
            RecordPageView::class,
        ],
    ];
}

use App\Http\Controllers\HomeController;
use RVxLab\Analytics\Middleware\RecordPageView;

Route::get('/', HomeController::class)->middleware([RecordPageView::class]);

// OR

Route::middleware([RecordPageView::class])->group(function () {
    Route::get('/', HomeController::class);
});
shell
php artisan vendor:publish --tag="analytics-migrations"

php artisan migrate
shell
php artisan vendor:publish --tag="analytics-config"