Integrating Yii 2 modules and frontend widgets with Craft CMS 3 I'm experienced in Yii2 framework, but I just discovered Craft CMS and I already love it.  

I use to develop Yii 2 modules using their own DB tables, models, controllers and views.
I usually use Yii extensions and widgets from Krajee (http://demos.krajee.com/widgets) for the frontend, to create rather complex forms.  

I'd like to integrate such modules and widgets in some pages of a Craft-managed website, using Craft for user management/access control and templating if possible.  

Which structure would you recommend ?  

Should I keep a separate instance of Yii 2 on the same server ?  If so, how can I integrate Yii2 views (PHP code) in Twig templates (no PHP) ?  

Or should I redevelop Craft modules or plugins using Twig ?  If so, how can I integrate Yii 2 frontend widgets and extensions in Twig templates and Craft CMS modules ?

Thanks in advance for your advice.
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!