Integrating Yii 2 modules and frontend widgets with Craft CMS 3
If you go down the route of creating your own modules for craft/yii2:

You can register access from twig to PHP services in your modules init() function

Event::on(CraftVariable::class, CraftVariable::EVENT_INIT, function(Event $e) {

        $e-&gt;sender-&gt;set('phpaccess',services\yourService::class);


    });


Access functions within this service in twig with

{% craft.phpaccess.yourfunctionname() %}


You could also return a twig template from your modules controller with some additional variables

$view = $this-&gt;getView();
$html = $view-&gt;renderTemplate(
    '/_templatename.twig',
    [
        'additionalvar' =&gt; $somephpvar
    ]
);

return $html;


Also if you havn't already seen the pluginfactory utility, it does save a lot of time!