Your destination for complete Tech news

How to create custom helper functions in Laravel

141 0
< 1 min read

To create custom helper functions in Laravel, you can create a custom helper.php file on the app folder and load it using the composer

Follow the steps below to use your custom helper function in Laravel.

Create a helper.php file in your app folder

Load the helper from your composer.json file

"autoload": {
    "classmap": [
        ...
    ],
    "psr-4": {
        "App\\": "app/"
    },
    "files": [
        "app/helpers.php" // INCLUDE THIS FILE
    ]
},

Finally, run composer dump autoload

composer dump-autoload

Leave A Reply

Your email address will not be published.

three − 2 =

This site uses Akismet to reduce spam. Learn how your comment data is processed.