PHPackages                             myhayo/diversion - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. myhayo/diversion

ActiveProject[Utility &amp; Helpers](/categories/utility)

myhayo/diversion
================

项目间相互倒流

v0.0.1(4mo ago)04PHPPHP ^8.0

Since Feb 27Pushed 4mo agoCompare

[ Source](https://github.com/myhayo/diversion)[ Packagist](https://packagist.org/packages/myhayo/diversion)[ RSS](/packages/myhayo-diversion/feed)WikiDiscussions main Synced today

READMEChangelog (1)Dependencies (4)Versions (2)Used By (0)

介绍
--

[](#介绍)

- 项目之间相互导流
- 安卓使用 google id 和 google 广告id 归因
- iOS 使用 ip加时间窗口归因

要求
--

[](#要求)

依赖说明[PHP](https://www.php.net/)`>=8.0`[Laravel](https://laravel.com/)`>=10`安装
--

[](#安装)

1.通过[Composer](https://getcomposer.org/)安。

```
composer require "myhayo/diversion"
```

2.发布文件

```
php artisan vendor:publish --provider="Myhayo\Diversion\DiversionServiceProvider"
```

3.执行 migrate

```
php artisan migrate
```

使用
--

[](#使用)

修改配置文件

```
    // 当前项目唯一标识
    'source_app_id'         => env('DIVERSION_SOURCE_APP_ID', 'walking_cash'),

    // iOS IP 归因的有效时间窗口（分钟）
    'ios_time_window_hours' => 30,

    // 接口路由前缀
    'route_prefix'          => 'diversion',

    // 引流项目列表
    'partners'              => [
        // 引流项目唯一标识
        'ai_cleaner_pro' => [
            'secret'         => 'secret_diversion_ai_cleaner_pro', // 秘钥
            'report_url'     => 'http://192.168.0.22:9034/diversion/click', // 上报引流记录链接
            'callback_url'   => 'http://192.168.0.22:9034/diversion/callback', // 完成引流回调链接
            // 引流回调事件处理
            'callback_event' => [
                'active' => '\App\Repositories\TaskRepository@completedNewbieTaskDiversionAiCleanerPro', // 激活事件处理函数
                'register' => null, // 注册事件处理函数
            ], // 回调事件处理 目前只支持激活和注册
        ],

        'walking_cash' => [
            'secret'         => 'secret_for_b', // 秘钥
            'report_url'     => 'http://192.168.0.22:9034/diversion/click', // 上报引流记录链接
            'callback_url'   => 'http://192.168.0.22:9034/diversion/callback', // 完成引流回调链接
            'callback_event' => [
                'active' => '\App\Repositories\TaskRepository@completedNewbieTaskDiversionAiCleanerPro', // 激活事件处理函数
                'register' => null, // 注册事件处理函数
            ], // 回调事件处理 目前只支持激活和注册
        ],
    ],
```

操作函数说明
------

[](#操作函数说明)

#### 上报引流 DiversionClient::report()

[](#上报引流-diversionclientreport)

```
DiversionClient::report(
    $partner_app_id, // 引流项目 唯一标识 为 配置文件里的 [ai_cleaner_pro]
    (string)Str::uuid(), // 上报记录唯一标识id
    $user->id, // 上报用户ID
    [
        'sys'       => $device_info->sys, // 系统 1-安卓 2-iOS
        'ip'        => $device_info->ip, // ip
        'aid'       => $device_info->aid ?? '', // 安卓ID
        'gid'       => $device_info->gid ?? '', // google id
        'timestamp' => time(), // 时间戳
    ],
);
```

#### 归因

[](#归因)

```
// 激活
$record = \Myhayo\Diversion\Services\DiversionAttribution::active(
    $sys, // 系统 1-安卓 2-iOS
    $aid, // 安卓ID
    $gid, // google id
    $ip // ip
);

// 注册
$record = \Myhayo\Diversion\Services\DiversionAttribution::registered(
    $sys, // 系统 1-安卓 2-iOS
    $aid, // 安卓ID
    $gid, // google id
    $ip // ip
);

$record =
{#2983
  +"id": 10
  +"diversion_id": "505e15a9-d828-458e-a9ab-fc77ec0c4f82"
  +"source_app_id": "walking_cash"
  +"source_user_id": "271684"
  +"sys": 1
  +"aid": "test111"
  +"gid": null
  +"ip_address": "192.168.65.1"
  +"actived_at": "2026-02-27 14:57:31"
  +"registered_at": null
  +"created_at": "2026-02-27 14:57:02"
  +"updated_at": "2026-02-27 14:57:02"
}

// 归因成功返回记录，无记录返回 null；项目自行处理渠道和后续步骤
```

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance77

Regular maintenance activity

Popularity3

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity29

Early-stage or recently created project

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

127d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/25251620?v=4)[EthanLau](/maintainers/EthanLau)[@ethanlau](https://github.com/ethanlau)

### Embed Badge

![Health badge](/badges/myhayo-diversion/health.svg)

```
[![Health](https://phpackages.com/badges/myhayo-diversion/health.svg)](https://phpackages.com/packages/myhayo-diversion)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[mike-bronner/laravel-model-caching

Automatic caching for Eloquent models.

2.4k91.0k1](/packages/mike-bronner-laravel-model-caching)[api-platform/laravel

API Platform support for Laravel

58171.5k14](/packages/api-platform-laravel)[pressbooks/pressbooks

Pressbooks is an open source book publishing tool built on a WordPress multisite platform. Pressbooks outputs books in multiple formats, including PDF, EPUB, web, and a variety of XML flavours, using a theming/templating system, driven by CSS.

45444.2k1](/packages/pressbooks-pressbooks)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
