# Error: "Cannot access protected property ..."

**URL:** https://discourse.cakephp.org/t/error-cannot-access-protected-property/9182
**Category:** Need Help
**Created:** [March 29, 2021, 9:48am UTC](https://discourse.cakephp.org/t/error-cannot-access-protected-property/9182 "2021-03-29T09:48:23Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Frank1000](https://avatars.discourse-cdn.com/v4/letter/f/dec6dc/32.png) [@Frank1000](https://discourse.cakephp.org/u/Frank1000)
#### Post date: [March 29, 2021, 9:48am UTC](https://discourse.cakephp.org/t/error-cannot-access-protected-property/9182/1 "2021-03-29T09:48:23Z")

</div>

Hi, following a tutorial for cake 3.7 … but actually working myself with 4.2.3, at the stage where I’m implementing a new theme (Gentelella-Master) I’m running into an error

“Cannot access protected property Cake\Http\ServerRequest::$webroot”

What type of problem is it and how can I prevent from it ?

Also, how would I may have found help on it myself ? I googled it and searched the community here but with no success yet.

---

<div class="post-metadata">

### Author: ![dirk](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/dirk/32/2174_2.png) [@dirk](https://discourse.cakephp.org/u/dirk)
#### Post date: [March 29, 2021, 10:45am UTC](https://discourse.cakephp.org/t/error-cannot-access-protected-property/9182/2 "2021-03-29T10:45:51Z")

</div>

maybe this could help:  
[https://api.cakephp.org/3.6/class-Cake.Http.ServerRequest.html#$webroot](https://api.cakephp.org/3.6/class-Cake.Http.ServerRequest.html#%24webroot)

So from 4.0.0 you have to use  
$this-\>request-\>getAttribute(‘webroot’)

---

<div class="post-metadata">

### Author: ![Frank1000](https://avatars.discourse-cdn.com/v4/letter/f/dec6dc/32.png) [@Frank1000](https://discourse.cakephp.org/u/Frank1000)
#### Post date: [March 29, 2021, 7:00pm UTC](https://discourse.cakephp.org/t/error-cannot-access-protected-property/9182/3 "2021-03-29T19:00:25Z")

</div>

Hey Dirk,  
thanks, that helped.  
Other question, how do I mark an answer as the solution ?

---

<div class="post-metadata">

### Author: ![Zuluru](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/zuluru/32/1230_2.png) [@Zuluru](https://discourse.cakephp.org/u/Zuluru)
#### Post date: [March 29, 2021, 11:18pm UTC](https://discourse.cakephp.org/t/error-cannot-access-protected-property/9182/4 "2021-03-29T23:18:57Z")

</div>

> [@Frank1000](#):
>
> Other question, how do I mark an answer as the solution ?

That’s a Stack Overflow thing, not a Discourse thing.
