Craft 3 – Render template as if it were a site request I have a Craft 3 plugin that renders a portion of an entry after save in order to index the resulting information. The plugin needs full access to the Twig extensions on the site to render the template, however several plugins that add such extensions check:

if( Craft::$app-&gt;getRequest()-&gt;getIsSiteRequest() )

As a result not all Twig extensions load when renderTemplate is called from the control panel. I set the template mode using:

Craft::$app-&gt;getView()-&gt;setTemplateMode(View::TEMPLATE_MODE_SITE)

but that only updates the path to the template. Is it possible to render the template as if it were a site request?
I suspect not without manually manipulating the path before the Request class is initialised. 

One possible alternative solution would be to use Guzzle to call the front-end URL rather than the CP URL, which will render the template with getIsSiteRequest set to true, for example:

$client = new \GuzzleHttp\Client();
$response = $client-&gt;request('get', 'http://url/front-end-template');
$body = $response-&gt;getBody();


It would also be possible to create your own controller which fetches the template and to hit it with a front-end action request:

$response = $client-&gt;request('get', 'http://url/actions/plugin/controller/action');