jeremykenedy/laravel-ip-capture
Composer 安装命令:
composer require jeremykenedy/laravel-ip-capture
包简介
A Laravel package to automatically capture and track IP addresses on Eloquent model actions such as signup, login, update, and deletion.
README 文档
README
A Laravel package to automatically capture and track IP addresses on Eloquent model actions such as signup, login, update, and deletion.
Table of Contents
Features
- Automatic IP capture on model events (signup, login, update, delete)
- Tracks 6 configurable IP columns per model
- Simple trait-based integration with any Eloquent model
- Proxy and load balancer aware (Cloudflare, X-Forwarded-For, etc.)
- Optional IP hashing for privacy compliance (SHA-256 or custom algorithm)
- Fluent interface for chaining multiple IP captures
- Configurable column names and enable/disable per column
- Publishable config, migrations, and translations
Requirements
| Dependency | Version |
|---|---|
| PHP | ^8.2 | ^8.3 |
| Laravel | ^10.0 | ^11.0 | ^12.0 | ^13.0 |
Installation
composer require jeremykenedy/laravel-ip-capture
Publish the config file:
php artisan vendor:publish --tag=ip-capture-config
Publish and run the migration:
php artisan vendor:publish --tag=ip-capture-migrations php artisan migrate
Configuration
The config file is published to config/ip-capture.php.
| Option | Type | Default | Description |
|---|---|---|---|
enabled |
bool | true |
Enable or disable IP capture globally |
null_ip |
string | '0.0.0.0' |
Fallback value when IP cannot be determined |
trust_proxies |
bool | true |
Use Laravel trusted proxy headers first |
hash |
bool | false |
Hash IP addresses before storage |
hash_algo |
string | 'sha256' |
Hashing algorithm (any algo supported by hash()) |
columns |
array | see below | Enable/disable individual IP columns |
Default Columns
| Column | Default |
|---|---|
signup_ip_address |
true |
signup_confirmation_ip_address |
true |
signup_sm_ip_address |
true |
admin_ip_address |
true |
updated_ip_address |
true |
deleted_ip_address |
true |
Environment variables:
IP_CAPTURE_ENABLED=true IP_CAPTURE_NULL_IP=0.0.0.0 IP_CAPTURE_TRUST_PROXIES=true IP_CAPTURE_HASH=false IP_CAPTURE_HASH_ALGO=sha256
Usage
Add the Trait
Add the CapturesIp trait to your User model (or any Eloquent model):
use Jeremykenedy\LaravelIpCapture\Traits\CapturesIp; class User extends Authenticatable { use CapturesIp; }
Available Methods
| Method | Description |
|---|---|
captureIp() |
Returns the current client IP as a string |
setSignupIp() |
Sets the signup IP address column |
setSignupConfirmationIp() |
Sets the signup confirmation IP column |
setSocialSignupIp() |
Sets the social media signup IP column |
setAdminIp() |
Sets the admin action IP column |
setUpdatedIp() |
Sets the updated IP column |
setDeletedIp() |
Sets the deleted IP column |
setIpColumn(string $column) |
Sets a specific IP column by name |
getIpColumns() |
Returns all populated IP columns as an array |
All setter methods return static for fluent chaining:
$user->setSignupIp()->setAdminIp()->save();
Custom Columns
Add a custom column to the config:
'columns' => [ 'signup_ip_address' => true, 'custom_ip_address' => true, // your custom column ],
Then use setIpColumn() to capture:
$user->setIpColumn('custom_ip_address');
IP Hashing
Enable hashing for privacy compliance:
IP_CAPTURE_HASH=true IP_CAPTURE_HASH_ALGO=sha256
When enabled, all captured IPs are hashed before storage. This is a one-way operation.
Testing
composer test
Or run Pest directly:
./vendor/bin/pest --ci
License
This package is open-sourced software licensed under the MIT license.
jeremykenedy/laravel-ip-capture 适用场景与选型建议
jeremykenedy/laravel-ip-capture 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1 次下载、GitHub Stars 达 1, 最近一次更新时间为 2026 年 03 月 28 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「security」 「Audit」 「laravel」 「IP」 「tracking」 「capture」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 jeremykenedy/laravel-ip-capture 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 jeremykenedy/laravel-ip-capture 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 jeremykenedy/laravel-ip-capture 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Log adding/updating/deleting of elements
Doctrine ORM provider for the auditor audit-log library.
Provide a way to secure accesses to all routes of an symfony application.
PB Web Media Audit Bundle for Symfony
It's a barebone security class written on PHP
Contao CMS integrity check for some files
统计信息
- 总下载量: 1
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 37
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-03-28