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
library
folder inside yourapp
folder - Edit
start/global.php
to addapp_path().'/library'
to theClassLoader::addDirectories(
array. - Edit
composer.json
to add"app/library"
to theautoload
array. - 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