Writing PHP into views field template twig I'm less familiar with D8, but I need to re-write a views field output using some PHP. I've made a custom field template HTML.twig file, but I'm not sure what I need to do to be able to run a PHP execution on my field to render it out as I want.
edit:
I am trying to run a function on the User ID as I have a module which hashes it before sending it to an external platform, however, now the client wants the understand which user is which, and the only way I can think to do this is by performing the same hashing code on the User ID in a format I can easily cross reference the user with their hashed output
I have a very basic view table showing only the User ID and email address, and I've managed to create a views field override using this page which has overwritten my field successfully. But now I want to run a command I'm going to copy from my contrib module, the below to be specific, so that I can work out which User ID relates to which hashed code
return Crypt::hmacBase64($uid, \Drupal::service('private_key')-&gt;get() . Settings::getHashSalt());
You can write Twig directly into your view with a Custom text field.

Using Twig as an entry point, you can use all of the Twig functionality and filters that ship with Drupal, as well as expanding on these with modules like Twig Tweak and Twig Field Value. You can also write your own Twig extensions, which are written in PHP. Here are two suitable tutorials:

https://opensenselabs.com/blog/tech/twig-extension-drupal
https://medium.com/@yuseferi/how-to-write-custom-twig-filter-in-drupal-8-1c2981dbf1e3