yii2 custom widget with custım controller

I am using yii2. I trying to create my custom widget in vendor directory. my class is working successfully. but I need custom controller in my widget directory and i need route to this controller/action. how can i create a widget like this ?

As you said it not widget. You need create yii2 module.

One module contain controllers,models and views. And widget just is a view.

Please read the Yii2 doucument carefully before asking.