Public function, simply put, this function can be used directly anywhere. Briefly introduce two implementation methods. First, create a new helpers.php file in the app directory to customize public functions.
Then you need to introduce this custom function,
The first method: Find the bootstrap folder in the project root directory,
As shown in the figure, Open the autoload.php file and introduce the previously defined helpers.php.
Second: Use composer to implement it. Find the composer.json file in the project root directory and introduce the custom function file in it, as shown in the figure
Then, Execute the composer dump-autoload command in the project root directory.
Both of the above two methods can realize the creation of public functions, and this custom function can be directly called from anywhere, which is very convenient.
Related recommendations:
Summary of commonly used custom public functions in js_Basic knowledge
The above is the detailed content of How to create custom public functions in larave5.4. For more information, please follow other related articles on the PHP Chinese website!