承接 brain-nucleus/client 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

brain-nucleus/client

Composer 安装命令:

composer require brain-nucleus/client

包简介

Official Brain Nucleus event client for Laravel and standalone PHP applications

README 文档

README

Official client for sending events to Brain Nucleus from Laravel applications.

This repo is the canonical standalone source for the reusable client/package layer.

It is distinct from:

  • MM BRAIN, which owns strategy, priority, interpretation, and history
  • Brain2026, which owns the SEO, research, builder, and orchestration lane
  • TheBrain, which is the control-plane application and is moving toward the function-led identity MM-Control-Plane

The package name brain-nucleus/client remains in place for compatibility. Any future package renaming should be staged carefully after downstream install/versioning impact is mapped.

🚀 Quick Start

1. Install via Composer

composer require brain-nucleus/client:dev-main

Note: First-time install? Add the repository to composer.json:

{
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/iamjasonhill/brain-client.git"
        }
    ]
}

2. Add Environment Variables

BRAIN_BASE_URL=https://again.com.au
BRAIN_API_KEY=your-api-key-here

Need an API key? Log into Brain Admin → API Keys → New API Key

3. Done! 🎉

That's it. The package auto-registers via Laravel's package discovery.

✅ What's Automatic (No Code Required)

Feature Description
Heartbeat health.ping sent every 5 minutes automatically
Singleton BrainEventClient ready for dependency injection
Command php artisan brain:heartbeat for manual testing

⚠️ What You Need to Implement

The package handles heartbeats automatically, but you must implement:

  1. Error Exception Handling → Send error.exception events
  2. Queue Failed Job Handling → Send queue.failed events

📋 See IMPLEMENTATION-CHECKLIST.md for complete code examples.

💻 Sending Events

Inject BrainEventClient anywhere in your application:

use Brain\Client\BrainEventClient;

class QuoteController extends Controller
{
    public function store(Request $request, BrainEventClient $brain)
    {
        $quote = Quote::create($request->validated());
        
        $brain->send('quote.created', [
            'quote_id' => $quote->id,
            'email' => $quote->email,
            'amount' => $quote->total,
        ]);
        
        return response()->json($quote);
    }
}

Async Events (Fire and Forget)

For non-blocking events:

$brain->sendAsync('page.viewed', [
    'page' => request()->path(),
    'user_id' => auth()->id(),
]);

⚙️ Configuration (Optional)

Publish the config file to customise behaviour:

php artisan vendor:publish --tag=brain-config

config/brain.php:

return [
    'base_url' => env('BRAIN_BASE_URL'),
    'api_key' => env('BRAIN_API_KEY'),
    
    'heartbeat' => [
        'enabled' => true,  // Set false to disable auto-heartbeat
        'interval' => 5,    // Minutes between heartbeats
    ],
    
    // Register site-specific custom events
    'events' => [
        'carrier.rate_received' => 'Rate received from transport carrier',
        'quote.manual_override' => 'Quote manually adjusted by staff',
    ],
];

🔄 Updating the Client

composer update brain-nucleus/client

📚 Documentation

Document Purpose
IMPLEMENTATION-CHECKLIST.md Required implementations (error handling, queue failures)
INTEGRATION-GUIDE.md Advanced code patterns and examples
OPS-EVENT-SPEC.md Event specifications and fingerprinting
EVENTS.md Business event definitions
docs/PACKAGE-IDENTITY-PLAN.md Staged package naming recommendation and compatibility constraints

🔗 Quick Links

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-12-22

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固