Laravel add custom helper function

1. In the APP directory, create Utils/CommonFunction.php


2. Add the auxiliary functions required by the business in CommonFunction.php.


3. Add in the autoload of composer.json:

The value corresponding to the files key is an array and the value is the path to the file relative to the file application root. After adding the above keywords in composer.json, run composer dump-autoload on the command line to let composer rebuild the loading information, then you can use this class in other files.

4. Call the helper function in the container:

Output result:


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324587958&siteId=291194637