larave5.4 How to implement a custom public function creation

Source: Internet
Author: User
Tags autoload

Public functions, simply speaking, can be used directly anywhere. Two methods of implementation are briefly introduced. First, create a new helpers.php file in the app directory, using the Customize public function.


Then you need to introduce this custom function,

The first method: the project root directory finds the Bootstrap folder,

, open the autoload.php file and bring in the previously defined helpers.php.

The second kind: using composer to implement, the project root directory found Composer.json file, inside the introduction of custom function file,

Then, execute the composer dump-autoload command under the project root directory.

Both of these methods can be used to create a common function, and can be directly called to this custom function anywhere, very convenient.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.