Writing PHP into views field template twig
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