Request Bean

scope is a bean of request type, the framework is not 初始化 when it is 初始化

Instead, lazy loading is used after the onRequest event is triggered.

It will not be initialized when the framework is initialized.

It will only be initialized when it is actually called. The singleton will be kept in the current request and will be automatically destroyed after the request ends. The scope is always in one request

use

Can only be obtained by getting BeanFactory::getRequestBean

 $obj = BeanFactory::getRequestBean($name, (string) $tid); 
  • Name requestBean name / alias / class name
  • The tid is usually bound to the 是顶级协程ID . Get the 顶级协程ID , Co::tid() get the 顶级协程ID current coroutine environment.

If you need to get the current request, 加载 those request bean . can use:

 $pool = BeanFactory::getContainer()->getRequestPool() 

destroy

After all coroutines have been executed, the request bean bound to the 顶级协程ID is 自动销毁 in the SwoftEvent::COROUTINE_COMPLETE event.

At this point, the life cycle of the request bean is over.

/docs/2.x/en/bean/request.html
progress-bar