title: initialize meta:

  • name: description content: 框架初始化事件
  • name: keywords content: swoole|swoole extension|swoole framework|EasySwoole|swoole|initialize

Framework initializes Events

The function prototype

  1. public static function initialize(): void
  2. {
  3. }

Finished work

EasySwoole has done the following when executing the framework initialization event:

  • The definition of the global constant EASYSWOOLE_ROOT
  • System default Log/Temp directory definition

Processable content

In this event, some system constant changes and global configuration can be made, for example:

  • Modify and create the system default Log/Temp directory。
  • Introduce user-defined configurations
  • Register database,redis connection pool
  • trace registration

Call the coroutine API before starting

  1. use Swoole\Coroutine\Scheduler;
  2. $scheduler = new Scheduler();
  3. $scheduler->add(function() {
  4. /* Call the coroutine API */
  5. });
  6. $scheduler->start();
  7. //Clear all timers
  8. \Swoole\Timer::clearAll();