codedreamer/footprint

Footprint 是一个 Laravel 扩展包,当用户与使用 Laravel 应用的客户端交互时,它会显示用户的设备、浏览器和远程 IP 信息,主要用于显示页面导航。

1.0.5 2020-06-10 23:56 UTC

This package is auto-updated.

Last update: 2024-09-11 15:20:47 UTC


README

A laravel package viewing clients IPs, browser information and Device Operating System.

Footprint

注意:在此阶段,我强烈建议使用路由名称。

要记录视图,可以使用 Footprint 静态 logTrail 方法,并将请求对象作为参数传递

<?php

use Footprint;

// log trail
public function index(Request $request){
	Footprint::logTrail($request);
	return view('welcome');
}

// log trail with description
public function task(Request $request){
	$request->description = "Task manager";
	Footprint::logTrail($request);
	return view('task');
}

安装

支持的 Laravel 版本为 7.x 及以上。

使用 Composer

$ composer require codedreamer/footprint
{
    "require": {
        "codedreamer/footprint": "^1.0.0"
    }
}
$ composer install

定位 Laravel 配置文件 config/app.php,添加 providers 和 aliases facades

<?php
 'providers' => [
    App\Providers\RouteServiceProvider::class,
    Codedreamer\Footprint\FootprintServiceProvider::class,
    ..................
 ]

 'aliases' => [
    'View' => Illuminate\Support\Facades\View::class,
    'Footprint' => Codedreamer\Footprint\Facades\Footprint::class,
    ..................
 ]

现在发布包到 vendor 目录以启用视图定制和迁移

$ php artisan vendor:publish --provider="Codedreamer\Footprint\FootprintServiceProvider"

现在运行迁移命令以迁移 footprints 表

$ php artisan migrate

文档

要记录每个传入的认证请求,请将 Footprint 静态类添加到 authenticate 请求中间件类内部

<?php

namespace App\Http\Middleware;

use Illuminate\Auth\Middleware\Authenticate as Middleware;
use Footprint;

class Authenticate extends Middleware
{
    /**
     * Get the path the user should be redirected to when they are not authenticated.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return string|null
     */
    protected function redirectTo($request)
    {
        // log trail
        Footprint::logTrail($request);

        if (! $request->expectsJson()) {
            return route('login');
        }
    }
}

要记录用户登录/注册,请将以下行添加到 Auth\LoginController 或 Auth\RegisterController

<?php

namespace App\Http\Middleware;

use Illuminate\Auth\Middleware\Authenticate as Middleware;
use Footprint;

class LoginController extends Controller
{
    // an example
    protected function login($request)
    {
        // log trail
        Footprint::logTrail($request);

        // code here...
    }
}

安全联系信息

即将推出

致谢

即将推出

贡献者

这个项目之所以存在,是因为所有贡献者的努力。

即将推出

翻译者

进行中

支持者

感谢所有支持者!🙏 成为支持者,让你的图像标签出现在这个包中

赞助商

通过成为赞助商来支持此项目。你的标志将在这里显示,并带有链接到你的网站。