danielcoulbourne/verbs-sync
Composer 安装命令:
composer require danielcoulbourne/verbs-sync
包简介
Simple CLI tool to sync Laravel Verbs events from a remote source
README 文档
README
A Laravel package that allows applications using Verbs to sync events from a remote source.
Overview
Verbs Sync is a simple CLI tool that enables a Laravel application using the Verbs package to pull events from another Verbs-powered application. This tool focuses on a straightforward pull-based syncing model where your application acts as the destination, pulling events from a remote source.
Features
- Pull Verbs events from a remote source application
- API token authentication for secure communication
- Selective event filtering
- Event deduplication to prevent duplicate processing
- Comprehensive logging
- Simple command-line interface
Installation
You can install the package via composer:
composer require danielcoulbourne/verbs-sync
After installing, publish the configuration file:
php artisan vendor:publish --provider="DanielCoulbourne\VerbsSync\VerbsSyncServiceProvider"
Run the migrations:
php artisan migrate
Quick Setup
- Install the package
- Publish the configuration
- Set your source URL and API token in your
.envfile - Run the sync command
Configuration
Configuration File
The package's configuration file (config/verbs-sync.php) contains the following settings:
source: Configuration for the remote source (URL and API token)events: Configuration for which events to sync (include/exclude)options: Syncing behavior options (batch size, retries)
Environment Variables
Configure the package using these environment variables:
VERBS_SYNC_SOURCE_URL=https://source-app.example.com
VERBS_SYNC_API_TOKEN=your-secure-token
VERBS_SYNC_INCLUDE_EVENTS=*
VERBS_SYNC_EXCLUDE_EVENTS=
VERBS_SYNC_BATCH_SIZE=100
VERBS_SYNC_RETRY_ATTEMPTS=3
Usage
To sync events from the source application:
php artisan verbs:sync
Options
--since=TIMESTAMP: Only pull events since this timestamp (ISO-8601 format)--types=type1,type2: Comma-separated list of event types to pull--limit=100: Maximum number of events to pull per batch--dry-run: Show what would be synced without actually syncing
Examples
Sync all events:
php artisan verbs:sync
Sync only specific event types:
php artisan verbs:sync --types=user.created,user.updated
Sync events since a specific time:
php artisan verbs:sync --since="2023-06-01T00:00:00Z"
Preview what would be synced:
php artisan verbs:sync --dry-run
How It Works
- The
verbs:synccommand makes a request to the source application's Verbs API - It fetches events based on your filters (event types, time range, etc.)
- For each event, it:
- Checks if the event has already been synced (to avoid duplicates)
- Stores a record of the event in the local database
- Processes the event through your local Verbs system
- Events are marked with
synced: truemetadata to prevent infinite loops
Database Tables
The package creates two tables:
verbs_sync_events: Tracks synced events with their source, type, and statusverbs_sync_logs: Records sync operations for monitoring and troubleshooting
Integrating with Scheduled Tasks
For regular syncing, you can add the command to your Laravel scheduler:
// In app/Console/Kernel.php protected function schedule(Schedule $schedule) { // Sync events every hour $schedule->command('verbs:sync')->hourly(); // Or with options $schedule->command('verbs:sync --types=user.created,order.placed --limit=200') ->dailyAt('02:00'); }
Testing
This package includes a comprehensive test suite. To run the tests:
composer test
Test Coverage
The test suite covers:
- Behavior tests for core functionality
- Command option processing
- Event filtering and deduplication
- Error handling scenarios
- End-to-end flow simulation
Troubleshooting
If you encounter issues with event syncing:
- Use the
--dry-runoption to see what would be synced - Check your Laravel logs for errors
- Ensure your API token is configured correctly
- Verify network connectivity to the source application
- Check that event types are not excluded in configuration
License
This package is open-sourced software licensed under the MIT license.
This package is open-sourced software licensed under the MIT license.
danielcoulbourne/verbs-sync 适用场景与选型建议
danielcoulbourne/verbs-sync 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2 次下载、GitHub Stars 达 2, 最近一次更新时间为 2025 年 07 月 07 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 danielcoulbourne/verbs-sync 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 danielcoulbourne/verbs-sync 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 2
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 10
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-07-07