如何在laravel中获得请求和响应的大小

如何在laravel中获得请求和响应的大小,laravel,Laravel,我在一个中间件中有这段代码,该中间件用于记录laravel应用程序中的数据流量 public function terminate($request, $response) { $method = strtoupper($request->getMethod()); $uri = $request->getPathInfo(); $message =now()."- {$method} {$uri} - R

我在一个中间件中有这段代码,该中间件用于记录laravel应用程序中的数据流量

    public function terminate($request, $response)
    {
        $method = strtoupper($request->getMethod());

        $uri = $request->getPathInfo();

        $message =now()."- {$method} {$uri} - Request Size{ $request_size } - Response Size{ $response_size }\n";
        file_put_contents(storage_path("requests.log"), $message,"\r\n".FILE_APPEND | LOCK_EX);
    }

我想知道请求和响应大小,怎么做?

请求大小和
strlen
响应大小请解释..上面有一个链接,解释了如何获取请求大小。对于响应,我假设它是JSON,您必须通过函数
strlen