Use $request in view composer
<p>I trying to write a view composer,</p>

<pre><code>class CountryCodeComposer
{

    function compose($view)
    {
         $code = substr(file_get_contents('http://ipinfo.io/' . $request-&gt;getClientIp() . '/country'), 0, 2);
       $view-&gt;with('code', $code);
    }
}
</code></pre>

<p>but this code show error <code>Undefined variable: request</code>,</p>

<p>How can I pass <code>$request</code> to compose method ?</p>