The ugly, lazy and awful way: At the end of
The clean way: Create a library. That way it'll be autoloaded ONLY when you actually use it.
bootstrap/start.php , add an include('tools.php') and place your function in that new file.The clean way: Create a library. That way it'll be autoloaded ONLY when you actually use it.
- Create a
libraryfolder inside yourappfolder - Edit
start/global.phpto addapp_path().'/library'to theClassLoader::addDirectories(array. - Edit
composer.jsonto add"app/library"to theautoloadarray. - Run
composer dump-autoload - Create your library file, create a class in it, and add static functions to it
- Call your class and static functions from your views.
No comments:
Post a Comment