Applications/YourApp/start_businessworker.php代码:
```php
<?php
...
require_once __DIR__ . '/../../vendor/autoload.php';
$worker = new BusinessWorker();
$worker->name = 'YourAppBusinessWorker';
$worker->count = 4;
$worker->registerAddress = '127.0.0.1:1238';
$worker->reloadable = true;
$worker->onWorkerStart = function($worker) {
require __DIR__ . '/../Trans/Trans.php'; //动态加载
};
if(!defined('GLOBAL_START'))
{
Worker::runAll();
}
```
在Events.php的onMessage()中测试:
```php
public static function onMessage($client_id, $message)
{
Trans::test($message);
}
```
Trans.php 代码:
```php
<?php
namespace Applications\Trans;
class Trans
{
public static function test($msg){
if($msg){
echo "\n$msg!----------------%%&";
}
}
}
```