register("hello", function (Context $context) { // You don't have to, but you should return a promise from your // commands. return new Promise(function (callable $resolve) use ($context) { Loop::addTimer(1, function () use ($context, $resolve) { $resolve("Hello, {$context->name}"); }); }); }); $commands->register("hello2", function (Context $context) { // Just returning the value works just fine! return "Hello2, {$context->name}"; }); // Create the bus $bus = new CommandBus($commands); // And execute some commands! $bus->execute('hello', ['name'=>'Bob'])->then( function ($result) { var_dump($result); } ); $bus->execute('hello2', ['name'=>'Bob'])->then( function ($result) { var_dump($result); } );