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();
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);
});