How do I access these values in the $request I am inside Handler.php function render($request, Exception $exception) and I did dd($request) and got this printed:
Request {#40 ▼
#json: null
#convertedFiles: null
#userResolver: Closure {#284 ▶}
#routeResolver: null
+attributes: ParameterBag {#42 ▶}
+request: ParameterBag {#48 ▶}
+query: ParameterBag {#48 ▶}
+server: ServerBag {#44 ▶}
+files: FileBag {#45 ▶}
+cookies: ParameterBag {#43 ▶}
+headers: HeaderBag {#46 ▶}
#content: null
#languages: null
#charsets: null
#encodings: null
#acceptableContentTypes: null
#pathInfo: "/listing/preview"
#requestUri: "/listing/preview"
#baseUrl: ""
#basePath: null
#method: "GET"
#format: null
#session: null
#locale: null
#defaultLocale: "en"
}
then I tried dd($request->pathInfo) but it prints null when it should print "/listing/preview"? How do I access these values?
Hey @maxnb you can actually call one of two methods to get that protected property.
$request->getPathInfo();
// or ...
$request->path();
pathInfo is a protected property and the Request class doesn't implement its __get() method in the way you would need it. Instead just use the methods above and you should be good to go.
@ craigpaul Thanks man, didn't know about that. Learn something new every day here at forums :)
Please sign in or create an account to participate in this conversation.