如何在micro phalcon应用中设置服务di的DI?当设置DI与服务不起作用时,如何处理该应用程序?
use Phalcon\Mvc\Micro;
use Phalcon\DI\FactoryDefault;
use Commonapi\App\Library\ApiServices as ApiServices;
class Bootstrap
{
public function run($opt){
$app = new Micro();
foreach ($loaders as $service) {
$function = 'init' . ucfirst($service);
$this->{$function}($app);
}
$services = new ApiServices($this->di);
$app->setDI($services->di);
return $app->handle();
}
//have loaded config,routes,loader by separate functions
答案 0 :(得分:-1)
为什么要将$app
完全传递给$function
?什么不起作用?有什么错误吗?也许做类似的事情:
foreach ($loaders as $service) {
$function = 'init' . ucfirst($service);
$this->{$function}();
}
$services = new ApiServices($this->di);
$app = new Micro($services->di);
return $app->handle();
究竟是什么ApiServices
?