承接 ismail1k/laravel-analytics 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

ismail1k/laravel-analytics

最新稳定版本:1.0.0

Composer 安装命令:

composer require ismail1k/laravel-analytics

包简介

A laravel package that can help you to measure traffic on your website!

README 文档

README

A laravel package that can help you to measure traffic on your website!

Installation

First, install Package to your laravel project with Composer using command bellow:

composer require ismail1k/laravel-analytics

then add these follow lines to config/app.php:

  'providers' => [
      Ismail1k\LaravelAnalytics\ServiceProvider::class,
  ],
  'aliases' => [
      'Tracker' => Ismail1k\LaravelAnalytics\CartServiceProvider::class,
  ],

Now, open app/Http/kernel.php and add this line:

  protected $routeMiddleware = [
       ...
      'tracker' => \App\Http\Middleware\TrackerMiddleware::class,
  ];

Next step, publish some files:

php artisan vendor:publish --provider="Ismail1k\LaravelAnalytics\ServiceProvider"

then, run the follow command line:

php artisan migrate

Usage

If you want to track all your routes, open app/Providers/RouteServiceProvider.php add tracker middleware to your web group routes like this:

  Route::middleware(['web', 'tracker'])
      ->group(base_path('routes/web.php'));

Also do this if you want to track your api group routes:

  Route::middleware(['api', 'tracker'])
      ->prefix('api')
      ->group(base_path('routes/api.php'));

Or you can track requests from Controller like this:

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Tracker;

class HomeController extends Controller
{
    public function index(Request $request){
        Tracker::log($request);
        return view('welcome');
    }
}

You can get sessions like using:

    $sessions = Tracker::sessions(60*24); //sessions for last 24H
    //Note: $sessions contain: IP, user, Location, Device, Browser, Traffic...

Or, If you want to get just the number of sessions:

    $traffic = Tracker::traffic(60*24); //traffics for last 24H

统计信息

  • 总下载量: 11
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-04-20