hotelmah/online-visitors
Composer 安装命令:
composer require hotelmah/online-visitors
包简介
Online Visitors package returns a PHP one-dimensional indexed array of GeoIP data with Remote IP Addresses and sorted DateTime differences for you to use as you wish like rendering to a view.
README 文档
README
This package returns a PHP one-dimensional indexed array of GeoIP data with Remote IP Addresses and sorted DateTime differences for you to use as you wish like rendering to a view.
Files Not Included in Packagist Package
- .gitattributes
- OnlineVisitors-Test-1.php
Test File
- OnlineVisitors-Test-1.php
- This is a sample of how the package works.
In your Script
- In each page that you want to record an online visitor, add the following (see the test file for an example):
require_once('vendor/autoload.php');
use function OnlineVisitors\{executeOnlineVisitorsInsertRow, executeGetOnlineVisitorsLatestIPAddressesWithTime};
- Call this function to insert a row into the database:
executeOnlineVisitorsInsertRow();
- Get the latest Online Visitors returned in an indexed array:
$SelectOptionsAry = executeGetOnlineVisitorsLatestIPAddressesWithTime();
- Process this returned array as you wish.
Installation - Composer
- run this command in your project root:
composer require hotelmah/online-visitors
- There is no need to manually create/update a composer.json file in your project root since this command does it automatically.
- The package is listed on Packagist, but is hosted on GitHub where the source is pulled from.
Installation - Manual
- Copy the src directory contents to an appropriately named directory like includes/ in your LAMP web hosting provider.
- Refer to the 'In your Script' heading above and/or test file.
Notes
- The script waits 10 minutes before updating the same Remote IP Address in the database. Thus, the visitor would need to be on your site for more than 10 minutes to see an update.
- 20 records are retrieved and sorted by most recent on top.
Database
- On your server and in your PHP.ini, ensure that SQLite3 is enabled and working.
- A sample SQLite3 database is not included in this repository because the script automatically creates the SQLite3 database if not found. If found, it simply updates the tables.
- The script creates/updates the SQLite3 database in your root web folder (html_public).
- SQLite3 does not require a username or password. Thus, there is no authentication to use the database.
- The database is a single file.
- The script must have read/write access to the folder the database is in.
- The database default name is OnlineVisitors.db.
- There should be no duplicate IP Addresses in the database unless the City, State, or Zip Code are different.
- You can delete the SQLite3 database on your server at will to start a new database, or rename the database to start a new database.
Third-Party Services
- This script uses cURL to get GeoIP data for the External Remote IP Address received.
- The GeoIP service is a free and publically available service.
- Your own External Remote IP Address is obtained from a free public service.
Feedback
- Forks and Pull Requests are welcomed.
- Suggestions and comments for improvement are requested.
- Thank you for reading!
Future Updates
- The latest 20 records are retrieved. This limit is not yet passed in as a parameter.
License
- GNU GENERAL PUBLIC LICENSE, Version 3.
hotelmah/online-visitors 适用场景与选型建议
hotelmah/online-visitors 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 6 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 11 月 29 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「curl」 「sqlite3」 「counters」 「Online Visitors」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 hotelmah/online-visitors 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 hotelmah/online-visitors 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 hotelmah/online-visitors 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
cURL and cURL based Soap-Client for PHP
Simple cURL wrapper
Exposes SQLite APIs that are otherwise not available in PHP
SQLite3 and Redis support for Zend Framework 1.11.xx backend cache
Sqlite and spatialite static binaries
A fluent PHP CURL wrapper
统计信息
- 总下载量: 6
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 32
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-3.0-only
- 更新时间: 2024-11-29