Global Event

EasySwoole has four global event. all of the events is located in EasySwooleEvent.php which is in your project root.


when this function was called,EasySwoole has done :

  • Log/Temp initialize

what you can do : you might change some php.ini setting,or change default set_error_handler\register_shutdown_function callback etc.


@param \EasySwoole\Core\Swoole\ServerManager $server
@param \EasySwoole\Core\Swoole\EventRegister $register
public static function mainServerCreate(ServerManager $server,EventRegister $register): void

when this function was called,EasySwoole has done :

  • global frameInitialize event
  • create main swoole server and register default callback

what you can do:

  • register main server callback
  • add a swoole sub listener
  • add a custom swoole process


use \EasySwoole\Core\Http\Request;
use \EasySwoole\Core\Http\Response;
public static function onRequest(Request $request,Response $response): ?bool

onRequest method will be called at each http request .

what can you doo :

  • you can filter the request params
  • you can add response info here
  • you can interupt a request here by $response->end()


results matching ""

    No results matching ""