roomies/fraudable 问题修复 & 功能扩展

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

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

roomies/fraudable

Composer 安装命令:

composer require roomies/fraudable

包简介

Integrate your Laravel app with AWS Fraud Detector

README 文档

README

Latest Version on Packagist GitHub Tests Action Status Total Downloads

Roomies Fraudable provides an integration layer between your Laravel app and AWS Fraud Detector. It leverages events and allows you to dispatch/ingest events for training, and later to predict events using your trained models.

Fraudable provides an integration between your Laravel app and AWS Fraud Detector. It leverages Laravel events as a way to ingest data to train models, and then to make predictions about events once you have collected enough data. It provides controls to update events as legitmate or fraudulent to improve your models, and to use prediction data to make assessments in your app.

Note that this is not a plug-and-play solution to detecting fraud. At the very least you will need to configure events, models and detectors in AWS Fraud Detector to get started.

Installation

You can install the package via Composer:

composer require roomies/fraudable

You can publish the config file with:

php artisan vendor:publish --tag=fraudable

Read through the config file to understand the AWS Fraud Detector integration and run the provided migration.

php artisan migrate

Getting started

First add Fraudable to the model(s) that will be your "entities" inside AWS Fraud Detector. By default we'll snake-case the full class name to be the "entity" name - App\Models\User will become app_models_user, as AWS Fraud Detector only allows lowercase letters and underscores.

namespace App\Models;

use Illuminate\Foundation\Auth\User as Authenticatable;
use Roomies\Fraudable\Concerns\Fraudable;

class User extends Authenticatable
{
    use Fraudable
}

Next, create events that will map to events inside AWS Fraud Detector. You can use regular Laravel extends and implement the FraudableEvent contract. It should return an instance of PendingEvent which will include the AWS Fraud Detector event name and the variables to be passed to the event. An instance of the current Illuminate\Http\Request will be provided to use for event variables.

namespace App\Events\Users;

use App\Models\User;
use Illuminate\Http\Request;
use Illuminate\Support\Str;
use Roomies\Fraudable\Contracts\FraudableEvent;
use Roomies\Fraudable\PendingEvent;

class UserCreated implements FraudableEvent
{
    /**
     * Create a new event instance.
     */
    public function __construct(public User $user)
    {
        //
    }

    /**
     * Get the fraud event representation of the event.
     */
    public function toFraudEvent(Request $request): PendingEvent
    {
        $name = Str::of($this::class)->replace('\\', '')->snake()->toString();

        return new PendingEvent(name: $name, variables: [
            'email' => $this->user->email,
            'user_agent' => $request->userAgent(),
        ]);
    }
}

In this example we also snake-case the full class name, so App\Events\Users\UserCreated becomes app_events_users_user_created inside AWS Fraud Detector.

Finally, you can now begin to ingest events for training or prediction.

$user = Auth::user();

$event = new App\Events\Users\UserCreated($user);

// Simply record the event to the database - an instance of `Roomies\Fraudable\Models\FraudEvent` is returned.
$fraudEvent = $user->ingest($event);

// Immediately upload the event for training.
$user->ingest($event)->upload();

// Get a prediction for the event
$predication = $user->ingest($event)->predict('detectorId');

When you make determinations about an entity you can retroactively update the recorded events.

use Roomies\Fraudable\Label;

$user = Auth::user();

$user->relabel(Label::Fraudulent);

roomies/fraudable 适用场景与选型建议

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

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-09-20