stounhandj / laravel-traffic-metrics
v0.1
2022-05-30 06:22 UTC
Requires
- php: ^8.0
- laravel/framework: ^7.0|^8.0|^9.0
- mateusjunges/laravel-kafka: ^1.7
This package is auto-updated.
Last update: 2024-10-29 06:25:30 UTC
README
A package for Laravel 6, 7, 8 to metrics unique page views using kafka
Installation
$ composer require stounhandj/laravel-traffic-metrics
Or
{ "require": { "stounhandj/laravel-traffic-metrics": "^0.1.0" } }
Setup
- Use following:
php artisan vendor:publish --tag=traffic-metrics php artisan vendor:publish --tag=laravel-kafka-config
According to the standard, a unique visit is considered to be a user's visit to the page once every 1 minute. This can be changed in the configuration. 2. Run migrations
php artisan migrate
- Set up a connection to kafka: In config/kafka.php setup brokers. More information here
- Add provider in config/app.php:
StounhandJ\LaravelTrafficMetrics\TrafficMetricsProvider::class,
- Add Middleware in Kernel.php:
'metrics' => \StounhandJ\LaravelTrafficMetrics\Middleware\MetricsMiddleware::class,
Usage
- Use Middleware:
Route::get('/p/{product:id}', [ProductController::class, "index"]) ->middleware("metrics") ->name("product.details");
- Put the handler on permanent execution:
php artisan metrics:check
- Getting metrics
Metrics::findByUri("/welcome")->getViews()