Home>Article>PHP Framework> How to set global method in laravel
Setting method: 1. Create a Common folder in the app directory, and create a new "function.php" file in it to store public functions; 2. Configure the "composer.json" file; 3. In the project directory, execute the "composer dump-autoload" statement.
The operating environment of this tutorial: Windows 7 system, Laravel version 5, Dell G3 computer.
laravel settings global method
1. Create a Common folder under the app, create a function.php under Common and put the public function
function test(){ echo 'this is a test'; }
2. In the project directory, configure composer.json and add the following code
"autoload": { "files":[ "app/Common/function.php" ] }
3. Execute the following command in the project directory
composer dump-autoload
Related recommendations:Latest Five Laravel video tutorials
The above is the detailed content of How to set global method in laravel. For more information, please follow other related articles on the PHP Chinese website!