See Manual:How_to_make_a_MediaWiki_skin#Extending_data
Can I write PHP code in the skins? if so what is the recommended way to do so?
This is covered in https://m.mediawiki.org/wiki/Manual:How_to_make_a_MediaWiki_skin#Extending_data