Home Laravel How to create helper file in laravel?

How to create helper file in laravel?

by therichpost
Published: Last Updated on 1 comment
Laravel 7.2 routing with route group auth guard check with prefix

Hello to all, welcome to therichpost.com. In this post, I will tell you, How to create helper file in laravel? Laravel is one of the top php mvc framework. Helper file in laravel helps to create global functions and these all are use in all laravel project.

Here is the way to create helpers file in laravel:

1. First create the file app/helpers.php and add below code in it:

 // print_r for debugging
 function pr($x){
   echo "<pre>";
   echo "</pre>";

2. Add below code into your composer.json file to call helpers.php file:

   "autoload": {
    "files": [

3. Run below command into your composer and this command automatically add this file into your laravel project:

   $ composer dump-auto

There are so many code tricks in laravel and i will let you know all. Please do comment if you any query related to this post. Thank you. Therichpost.com

You may also like

1 comment

Julien Pitt October 4, 2019 - 4:52 am





Leave a Comment

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