Where should PHP file of custom widget be in?
If it were my project, I would probably put the PHP file in modules

Here's some more info https://docs.craftcms.com/v3/extend/ and here: https://docs.craftcms.com/v3/extend/module-guide.html