Lumen/laravel添加全局自定义函数
1.创建自定义文件
- 在任意文件夹下新建一个 functions.php 文件
- 如:”app/Common/Functions/functions.php”
2.配置自动加载
- 在 composer.json 文件中添加配置
{ "autoload": { "files": [ "app/Common/Functions/functions.php" ] } }
3.重新加载配置
- 运行命令:$ composer dump-auto
{ "autoload": { "files": [ "app/Common/Functions/functions.php" ] } }