Jump to:

23486 Posts in 18995 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » How to trace file access when a page is browsed

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 461 Views
  • simples
    Avatar
    Community Member
    76 Posts

    How to trace file access when a page is browsed Link to this post

    Hi,

    I would like to move some generic code into a module. In order to help me do this I would like some visibility of file access when a page is browsed.

    What would be the easiest way of achieving this?

    When I browse the home page of my site in my dev installation by adding debug tools into the URL in a fresh installation of 2.4.7, I see no extra information.

    For example adding ?debug_request=1 to http://acer/kenton/candy/home, where http://acer/kenton/candy is the root, shows no debug information. In fact when I browse http://acer/kenton/candy/home?debug_request=1, the page just renders as normal.

    I am using Version 2.4.7 (My client's host runs PHP 5.2) in a WAMP stack and have tried IE8, Chrome (latest version) and FF (latest version). Nothing works.

    Has anyone any idea of what I may have overlooked and what I need to do differently?

    Thanks.

  • simples
    Avatar
    Community Member
    76 Posts

    Re: How to trace file access when a page is browsed Link to this post

    Ok, I appear to be a step closer to sussing out how to list what files are accessed when a page is requested.

    In order for the debug tools to work when variables are added to the URL, I needed to add the following line to mysite/_config.php.

    /**
    * Set environment: 'dev', 'test', or 'live'.
    */
    Director::set_environment_type('dev');

  • simples
    Avatar
    Community Member
    76 Posts

    Re: How to trace file access when a page is browsed Link to this post

    Hi,

    It looks like it is currently not possible to get a complete list of files accessed in the order in which access occurs.

    The best I could find was adding either

    user_error("breakpoint", E_USER_ERROR)

    or

    SS_Backtrace::backtrace

    into a class function depending on whether or not I want script execution to stop at the point of insertion.

    Obviously this does not give a complete list from start to finish after a page is requested and rendering stops.

  • Willr
    Avatar
    Forum Moderator
    5508 Posts

    Re: How to trace file access when a page is browsed Link to this post

    According to the docs that should work. Do you get any output if you use ?show_templates=1 or any of the other URL variables (http://doc.silverstripe.org/framework/en/2.4/reference/urlvariabletools..

    You can also use tools such as XHProf for generating callgraphs and execution maps.

  • simples
    Avatar
    Community Member
    76 Posts

    Re: How to trace file access when a page is browsed Link to this post

    Thanks Willr for the tips.

    The other tools worked as expected but none of them went from start to finish where finish is the last file accessed before the last element in the requested page is rendered onto the screen.

    PS. I tried to Google and enter "?show_templates=1" in the above search box which is placed just above Jump to:. Nothing was returned by Google (when I searched for ["silverstripe" "show_templates"] without the brackets) and when I entered "show_templates" into the above search box without the quotes, all I saw returned was this post. Did you mean ?showtemplate=1

    461 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.