Best Practices for Custom Helpers in Laravel 7

I would like to create helper functions to avoid repeating code between views in Laravel 7 : master.blade.php

<p>Demo text: {{ capitalText($text) }}</p>

They’re basically text formatting functions. Where and how can I create a file with these functions?

Default Asked on June 18, 2020 in Programming.
Add Comment
1 Answer(s)

Create a helpers.php file in your app folder and load it up with composer:

"autoload": {

    "classmap": [



    "psr-4": {

        "App\\": "app/"


    "files": [

        "app/helpers.php" // <---- ADD THIS



In the wake of adding that to your composer.json file, run the accompanying order:

composer dump-autoload

Default Answered on June 22, 2020.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.