Probably the most elegant way would be to write the php file as a Bolt extension that declares a Twig function. Then call the function from the template. See this section of the docs for details: https://docs.bolt.cm/extensions#add-a-twig-function-or-filter, the top of the page has information on how to create an extension - use the wizard to create an empty extension with a Twig function and then drop your php code into it at the right point.