laravel 如何引入自己的函数或类库

例如在app下建一个Common文件夹 在Common下建一个function.php 放入公共函数

例如:
function test(){
        echo 'this is a test';
    }
在项目目录下composer.json中加入

"autoload": {
    "files":[
        "app/Common/function.php"
    ]
}
在项目目录下执行
composer dump-autoload

在控制器的某个方法中调用
public function aa(){
    test();    
}

原文地址:https://www.cnblogs.com/fps2tao/p/7846065.html