document_root

此功能较为简易, 请勿在公网环境直接使用

配置静态文件根目录,与enable_static_handler配合使用。

  1. $server->set([
  2. 'document_root' => '/data/webroot/example.com',
  3. 'enable_static_handler' => true,
  4. ]);

设置document_root并设置enable_static_handlertrue后,底层收到Http请求会先判断document_root路径下是否存在此文件,如果存在会直接发送文件内容给客户端,不再触发onRequest回调。

1.9.17或更高版本可用
使用静态文件处理特性时,应当将动态PHP代码和静态文件进行隔离,静态文件存放到特定的目录