例如在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();    
}

 


 
                    
            
                

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-10
  • 2022-12-23
  • 2021-09-11
  • 2021-08-24
  • 2021-11-02
猜你喜欢
  • 2021-05-15
  • 2021-07-22
  • 2022-12-23
  • 2021-08-11
相关资源
相似解决方案