Tencent / Biny

Biny is a tiny, high-performance PHP framework for web applications
BSD 3-Clause "New" or "Revised" License
1.69k stars 259 forks source link

同级Serveice无法相互调用 #81

Closed tiltysola closed 5 years ago

tiltysola commented 5 years ago

questsService中无法调用gameplayService中的方法。

命名空间: namespace app\service;

代码: $total = $this->gameplayService->get($this->$member['id']);

错误Stack:

Fatal error:  System Error [Uncaught Error: Call to a member function get() on null in app/service/questsService.php:54
Stack trace:
#0 app/controller/questsAction.php(47): app\service\questsService->quest_able_accomplish('1')
#1 [internal function]: app\controller\questsAction->action_quest_submit()
#2 lib/business/TXController.php(69): call_user_func_array(Array, Array)
#3 lib/business/TXController.php(42): biny\lib\TXController->call(Object(biny\lib\TXRequest))
#4 lib/business/TXController.php(105): biny\lib\TXController->execute()
#5 lib/TXApp.php(177): biny\lib\TXController->dispatcher()
#6 web/index.php(21): TXApp::run()
#7 {main}
  thrown] in lib/TXApp.php:156
Stack trace:
#0 [internal function]: TXApp::handleFatalError()
#1 {main}
billge1205 commented 5 years ago

框架不建议同级service间相互调用,如果真要使用,可以这样写 biny\lib\TXFactory::create('gameplayService')->get($this->$member['id']);

tiltysola commented 5 years ago

谢啦,我通过修改TXService也完成了同级调用操作。

billge1205 commented 5 years ago

good job~ 注意不要调用死循环就行