1、在 app/Helpers/ 新建一个文件 functions.php,当然这个文件位置和名称你可以自己定义,创建一些函数用于全局调用:
app/Helpers/ 新建一个文件
functions.php
2、在composer.json中的autoload下增加如下代码加载自动文件
composer.json
autoload
3 执行composer命令让其自动加载:
composer
composer dump-auto
加载成功后,我们就可以在任何地方使用上面创建的全局函数库了