Jump to:

23480 Posts in 18951 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » [SOLVED] SilverStripe & PHP - Where is the root directory?

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: 1270 Views
  • jizzman
    Avatar
    Community Member
    23 Posts

    [SOLVED] SilverStripe & PHP - Where is the root directory? Link to this post

    Hi,

    This is probably a simple one. I have SS installed in a directory under document root: i.e. <document root>/<my website>/<the SS framework>

    Inside a PHP controller member function how I can find the <the SS framework> directory? I want to scan a list images in a directory I have created under assets using "scandir(<path>)". I can't specify the path like this "/assets/images/banner" because SS is not installed at document root level. I want to avoid if I can specifying "/<my website>/assets/images/banner" because that ties me to the parent directory name. When I give a relative path, scandir() complains it can't find the directory as PHP appears to be pointing to the sapphire directory. If I specify a relative path like this "../assets/images/banner" then it works. But that's a bit ugly in my book. My intuition tells me there's a variable for function somewhere in the Sapphire framework.

    Thank-you,
    J

  • simon_w
    Avatar
    Forum Moderator
    473 Posts

    Re: [SOLVED] SilverStripe & PHP - Where is the root directory? Link to this post

    ASSETS_PATH is a constant that contains the path to the assets folder (no trailing slash).

  • jizzman
    Avatar
    Community Member
    23 Posts

    Re: [SOLVED] SilverStripe & PHP - Where is the root directory? Link to this post

    That's depressingly simple. Thanks

    1270 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.