Retrieving an entry based on the request URI in a plugin controller I'm working a plugin and part of the task is to grab the entry based on the current URI using craft()-&gt;request-&gt;getRequestUri().

Is there a way to grab the entry based on the URI from the request?
You can grab the current entry using the $uri = craft()-&gt;request-&gt;getRequestUri() which will return the URI in a format like so: 

/path/to/uri

To grab the entry, its easiest to grab the element first, based on the URI, using craft()-&gt;elements-&gt;getElementByUri($uri). However, this will not work because of the beginning slash that is returned by getRequestUri. So you must remove the slash using ltrim like so: 

$uri = ltrim(craft()-&gt;request-&gt;getRequestUri(), '/')

Once you have the URI, minus the beginning slash (path/to/uri), you can use $element = craft()-&gt;elements-&gt;getElementByUri($uri) to return the element and then grab the entry using $entry = craft()-&gt;entries-&gt;getEntryById($element-&gt;id).

If you were going to need this often, you can place it in a helper method on the controller.

private function getEntryByRequestUri()
{
    // remove the first trailing slash
    $uri = ltrim(craft()-&gt;request-&gt;getRequestUri(), '/');
    $element = craft()-&gt;elements-&gt;getElementByUri($uri);
    $entry = craft()-&gt;entries-&gt;getEntryById($element-&gt;id);
    if ($entry == null) {
        // log something and do something
    }
    return $entry;
}