例如在app下建一个Common文件夹 在Common下建一个function.php 放入公共函数
例如:
- function test(){
- echo 'this is a test';
- }
在项目目录下composer.json中加入
- "autoload": {
- "files":[
- "app/Common/function.php"
- ]
- }
在项目目录下执行
在控制器的某个方法中调用
- public function aa(){
- test();
- }
以上这篇laravel 如何实现引入自己的函数或类库就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持w3xue。