# page.docRootPath bug!

**URL:** <https://forums.realmacsoftware.com/t/page-docrootpath-bug/47729>\
**Category:** Elements\
**Created:** [May 24, 2025, 12:09pm UTC](https://forums.realmacsoftware.com/t/page-docrootpath-bug/47729 "2025-05-24T12:09:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![logrunner](https://avatars.discourse-cdn.com/v4/letter/l/59ef9b/32.png) [@logrunner](https://forums.realmacsoftware.com/u/logrunner)\
**Post date:** [May 24, 2025, 12:09pm UTC](https://forums.realmacsoftware.com/t/page-docrootpath-bug/47729/1 "2025-05-24T12:09:07Z")

</div>

I have a php file which is placed two levels down from the website root folder, that uses a Component to generate some of the PHP code:

```auto
webroot
    level_1_folder
        level-2_folder
            index.php
                (Component included in index.php)

```

In the Component hooks.js, the page property **docRootPath** is being returned as:

```auto
../../../

```

It should be being returned as:

```auto
../../

```

Currently this is causing an error in my PHP code, as a ‘required’ PHP file which is in another folder at the root level isn’t being found, due to this path being incorrect.

Editing the published index.php file and substituting the corrected value:

```auto
../../

```

corrects the issue.

I checked the published code in an index.php file (that includes the same component) residing in a level\_1\_folder, this correctly returns **docRootPath** as:

```auto
../

```

---

<div class="post-metadata">

**Author:** ![ben](https://dub1.discourse-cdn.com/flex005/user_avatar/forums.realmacsoftware.com/ben/32/28488_2.png) [@ben](https://forums.realmacsoftware.com/u/ben)\
**Post date:** [May 26, 2025, 7:49am UTC](https://forums.realmacsoftware.com/t/page-docrootpath-bug/47729/2 "2025-05-26T07:49:15Z")

</div>

are you publishing to a sub-folder?

Can you share the hooks file or code you’re using to get the docRootPath?

---

<div class="post-metadata">

**Author:** ![logrunner](https://avatars.discourse-cdn.com/v4/letter/l/59ef9b/32.png) [@logrunner](https://forums.realmacsoftware.com/u/logrunner)\
**Post date:** [May 26, 2025, 10:50am UTC](https://forums.realmacsoftware.com/t/page-docrootpath-bug/47729/3 "2025-05-26T10:50:42Z")

</div>

I have tried to recreate the issue in a small project but failed to do as it works OK! 🤔

The structure In [Elements](https://elementsapp.io/) I had was like this:

 ![CleanShot 2025-05-25 at 15.07.24](https://europe1.discourse-cdn.com/flex005/uploads/realmacsoftware1/original/3X/0/5/058f6ce8a63d4edc965310e074b7ebd9a0eb2b61.png)

The files on disk look like this:

 ![CleanShot 2025-05-25 at 15.11.47](https://europe1.discourse-cdn.com/flex005/uploads/realmacsoftware1/original/3X/f/8/f829a499087ef2d1cabbe8038a340293fbd653d6.png)

I don’t want to wast your time looking at this, especially as I can’t easily reproduce it in a small project file as I can work-around the issue.

I have done this by moving the **Events - View** and **Events - Edit** pages up a level and now the **docRootPath** is being returned OK. They don’thave to be at a lower level, it just made the structure nicer.

If I manage to recreate the issue in the smaller project, I will update this thread.

---

<div class="post-metadata">

**Author:** ![ben](https://dub1.discourse-cdn.com/flex005/user_avatar/forums.realmacsoftware.com/ben/32/28488_2.png) [@ben](https://forums.realmacsoftware.com/u/ben)\
**Post date:** [May 26, 2025, 11:36am UTC](https://forums.realmacsoftware.com/t/page-docrootpath-bug/47729/4 "2025-05-26T11:36:43Z")

</div>

ok, thanks for the update! Do let us know if you manage to replicate the issue 🙂
