Best way to implement a global utility function

Problem

Some other frameworks and CMS's you have used have - for example - a handy function called "h", which is a shortcut to htmlspecialchars($string, ENT_QUOTES, 'utf-8'). This makes it super-easy to escape output in your templates. In ProcessWire, there is by default no such helper present by default.

Solution

Using own utility function files in my site-profiles in a subfolder called, for example: 'mylibs'

How to include them once in the site/config.php file:

include_once(dirname(__FILE__) . "/mylibs/myfunctions.php");

This way you can use all what the features/methods this utility files everywhere.

Resources

Version

1.0.0

View/correct recipe on GitHub

https://github.com/processwire-recipes/Recipes/blob/master/best-way-to-implement-a-global-helper-function.md

Author(s)