sarfraznawaz2005/visitlog 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

sarfraznawaz2005/visitlog

Composer 安装命令:

composer require sarfraznawaz2005/visitlog

包简介

Laravel package to log visitor information into database.

README 文档

README

Total Downloads

Introduction

VisitLog is a simple Laravel 5 package that can be used to log visitor information and save it into database.

Features

  • Other than basic log such as IP, Browser and OS, it can also log Location information.
  • Allows to log both unique and non-unique visits based on IP.
  • Allows to cache the visits based on IP.
  • Allows to log authenticated user info.
  • Provides log viewer page out of box.
  • Provides basic http authentication for app users.
  • Ability to ban users by their IP

Note: VisitLog cannot detect same user/IP coming from some anonymizer so it cannot differentiate that.

Screenshot

Main Window

Note: Info in above screenshot is fake.

Requirements

  • PHP >= 5.5.9
  • Laravel 5

Installation

Install via composer

composer require sarfraznawaz2005/visitlog

For Laravel < 5.5:

Add Service Provider to config/app.php in providers section

Sarfraznawaz2005\VisitLog\VisitLogServiceProvider::class,

Add Facade to config/app.php in aliases section

'VisitLog' => Sarfraznawaz2005\VisitLog\Facades\VisitLog::class,

Run php artisan vendor:publish to publish package's config and migration file. You should now have config/visitlog.php file published. It will also publish migration file in database/migrations folder.

Run php artisan migrate to create visitlogs table in your database.

Config Options

  • route : Route where visit log will be available.
  • iptolocation : By default, only IP, Browser and OS info is logged. However if you set this option to true, it will also log Location info through https://ipstack.com/ service. Note: You will need to create account there and get your access key and specify that in visitlog config file.
  • cache : If iptolocation is set to true, this option can be used to cache the results instead of requesting Location info each time from https://ipstack.com/.
  • unique : If true, it will only log unique visits based on IP address. If false, it will log each visit even from same IP.
  • log_user : If true, it will also log authenticated user info.
  • user_name_fields : If log_user is true, this option can be used to specify name fields of user from your Users table in database.
  • visitlog_page : If true, a default log viewer page can be viewed at http//yourapp.com/your_route to see all the logs. Here your_route is the first option above.
  • http_authentication : If visitlog_page is true, this option can be used to show visit log page to only authenticated app users by asking them email and password via basic http authentication.

Saving Log Info

To save logs, just call save method of VisitLog facade: VisitLog::save();

Tip: If you want to save only unique logs based on IP, login or post-login page is good place to use the save method on because generally login page isn't visited again after user is authenticated. If you also want to save authenticated user, calling save method inside login post method seems to be good idea.

If however, you have set unique option to false and want to log all visits, calling save method in common location is good idea like base controller of your app.

Viewing Log Info

If config option visitlog_page is set to true, you can view all visit logs by browsing to http//yourapp.com/your_route.

Note: If you don't want to allow visitlog page to be publicly seen, set the option visitlog_page to false and now http//yourapp.com/your_route will result in 404 error.

In this case, you can still show log info in some authenticated area of your app by using all method of VisitLog facade: $visitLogs = VisitLog::all(); and it will give you Collection that you can iterate over and show in your own view file.

Credits

License

This code is published under the MIT License. This means you can do almost anything with it, as long as the copyright notice and the accompanying license file is left intact.

sarfraznawaz2005/visitlog 适用场景与选型建议

sarfraznawaz2005/visitlog 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 17.11k 次下载、GitHub Stars 达 88, 最近一次更新时间为 2016 年 09 月 13 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「log」 「laravel」 「visitor」 「IP」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 sarfraznawaz2005/visitlog 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 sarfraznawaz2005/visitlog 我们能提供哪些服务?
定制开发 / 二次开发

基于 sarfraznawaz2005/visitlog 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

  • Stars: 88
  • Watchers: 2
  • Forks: 31
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-09-13