📜  在 laravel 中创建一个全局 php 函数,以便在任何地方访问 - PHP 代码示例

📅  最后修改于: 2022-03-11 14:54:11.286000             🧑  作者: Mango

代码示例1
function your_function( $parameters ) {
    //function logic
} 

function your_another_function( $parameters ) {
    //function logic
} 

// composer.json
"autoload": {
    ...
    "files": [
        "app/Helpers/your_helper_function.php"
    ]
    ...
}

// Now call from any class of Laravel
class UserController extends Controller {
   
  public function storeUser() {
      your_function();
    
    // do other stuffs
  }

}