Skip to content
● Grav 2.2 is out: 2x faster cold starts and 96% less memory on big sites. Read the announcement →

How to access object properties in Grav?

Started by Alexander Kim 9 years ago · 1 replies · 929 views
9 years ago

Here's the output of dump(Grav::instance()['uri']):

image|435x500

I've tried to get #paths[2] this way Grav::instance()['uri']->paths[2], but i'm getting this error: Cannot access protected property Grav\Common\Uri::$paths

9 years ago

It's protected by the class definition. You're not allowed to access it directly. What exactly are you trying to get out of the object? If you look at the URI API, you'll see there's a path() method that may get you what you're looking for.

Suggested topics

Topic Participants Replies Views Activity
General · by Andy Miller, 6 days ago
0 109 6 days ago
General · by lynbor, 1 month ago
3 438 2 weeks ago
General · by lynbor, 3 weeks ago
7 558 2 weeks ago
General · by Harry, 2 weeks ago
0 160 2 weeks ago
General · by Old Man Umby, 1 month ago
2 309 3 weeks ago