Best Way For Extend Existing Widget

Hi all, who can tell me the correct way to extend an existing widget? Considering the advanced installation of Yii2 which folder should I build the structure?

In /common/component/… or other ?


Framework doesn’t force you to put your classes in cetain locations so use what makes sense to you. I’d mimic original widget parent dirs.

@samdark thanks, for the moment I put the new widget in /frontend/widgets/ path ;)

Good choice.

Is there anyway to write in short code ? Ex:




, i want to write in: app(), and create a function to handle it

function app() { return Yii:$app; }

Is it safe for use it as global config ? Where’s the best place ?


Yes, it’s OK. Just don’t use such code in anything publically distributable such an extension.