rmasters/stack-timer

简单的StackPHP中间件,用于计时

v1.0.0 2014-01-07 19:02 UTC

This package is not auto-updated.

Last update: 2024-09-24 03:46:01 UTC


README

A simple StackPHP middleware that reports on the time it takes the inner middlewares/app to run. Written to figure out what Stack can do 😃

用法

只需将计时中间件包装在您的应用程序中,负载时间就会注入到响应体中。

$app = new App(); // implements HttpKernelInterface
$timer = new StackTimer($app);

$request = Request::createFromGlobals();
$timer->handle($request)->send();

选项

StackTimer::__construct(HttpKernelInterface, array)传递一个包含以下任何键的数组

  • inject (布尔值,默认:false) - 是否注入到响应体中,
  • callbacks (可调用函数|可调用函数数组) - 传递以下参数的闭包/可调用函数数组:function(HttpFoundation\Request $request, float $microseconds)
  • format (字符串,默认:{ms}ms) - 要注入的文本,下面是替换字符串的列表。
  • wrapper (字符串,默认:<div style="...">%s</div>) - 包含文本的HTML,必须包含一个%s,其中将添加文本。
  • injection (字符串,默认:</body>) - 在何处注入片段,此值通过preg_quote传递,不能包含正则表达式。
  • inject_before (布尔值,默认:true) - 是否在注入点之前(即</body>之前)注入片段。