控制器:
class BaseController extend Comtroller(){
public static function staticLoadFunction($functionName){
require_once(app_path().'/Function/'.$functionName);
} //创建了一个静态方法}
Function:(自己创建的于Http同级laravel版本5.4)
//位置:Function/test/testFunction.php function testFunction (){
$val = '我是function中的函数'
return json_decode($val,true);
}
Middelware:(中间件)
public function handle($request Closure $next){ BaseController::staticLoadFunction('test/testFunction.php');
//填写他的位置
$FunctionVal = \testFunction();
echo $FunctionVal;//会输出:我是function中的函数
}