Laravel Request getting current path with query string

John Bupit picture John Bupit · Jul 22, 2015 · Viewed 104.4k times · Source

Is there a Laravel way to get the current path of a Request with its query parameters?

For instance, for the URL:

http://www.example.com/one/two?key=value

Request::getPathInfo() would return /one/two.

Request::url() would return http://www.example.com/one/two.

The desired output is /one/two?key=value.

Answer

Hubert Dziubiński picture Hubert Dziubiński · Sep 20, 2016

Try to use the following:

\Request::getRequestUri()