How to create custom public functions in larave5.4

小云云
Release: 2023-03-21 14:12:01
Original
1317 people have browsed it

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.

How to create custom public functions in larave5.4
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.
How to create custom public functions in larave5.4
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
How to create custom public functions in larave5.4
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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template