I have a question about Zend Framework 2.I want to find out how much time take to complete a request and I know that it should be possible using Zend MVCEvent but I don't know how.
相关问题
- Why does recursive submodule update from github fa
- How to pass options/params to formCollection field
- Compress html output from zend framework 2
- How to force resolve a promise after certain durat
- Google recaptcha remoteip explanation
相关文章
- Python Requests - Dynamically Pass HTTP Verb
- android httprequest java.net.UnknownHostException
- How to display the request sent time and the respo
- Zend Framework 2 Forms Array notation for drop dow
- Upload image through form data using python reques
- Node.js request data event not firing. What am I d
- How to use blogger video as iframe (Error 400)
- RESTful Webservice does not handle Request Method
This don't exactly answer your question but I think you could do such a thing using the
REQUEST_TIME
that you can get from the request server. Something like this :And then at the end of the request :
I'm not sure but I think this module ZendDeveloperTools permits to show the execution time.
a better solution in my mind is to replace a special variable inside your template files like this
{{ renderTime }}
so you are free to controll the text position and don't mess up json response models in your zf application.
let me explain why i don't hook up into the
\Zend\View\ViewEvent::EVENT_RENDERER
event and replace my variable directly in theResponse
at theFINISH
event.basically you can't use the other events, because the page is not rendered at any time and all the functions/viewhelper into your template are currently not done and so the time would be less then the real render time.
The
\Zend\View\ViewEvent::EVENT_RENDERER_POST
Event is not good because - your view is rendered thats true - but the application is not done and maybee all the registered events etc that follow are not executed yet.if you like my idea than your
index.php
would look like thisand your
module.php
onBootstrap
method would become thisand in your template/layout file set where you wish to inject the rendertime with
{{ renderTime }}
that now gives you
page render time - 0.67307 seconds
This is the solution I've came up with,the code is write in Module.php on the Module that I want to display request time on every page: