Categories

Wednesday, April 24, 2024
#919814419350 therichposts@gmail.com
Laravel

How to create helper file in laravel?

Laravel 7.2 routing with route group auth guard check with prefix

Create helper file in laravel

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:

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


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

   "autoload": {
    "files": [
      "app/helpers.php"
    ]
   },

/********************************************/
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

therichpost
the authortherichpost
Hello to all. Welcome to therichpost.com. Myself Ajay Malhotra and I am freelance full stack developer. I love coding. I know WordPress, Core php, Angularjs, Angular 14, Angular 15, Angular 16, Angular 17, Bootstrap 5, Nodejs, Laravel, Codeigniter, Shopify, Squarespace, jQuery, Google Map Api, Vuejs, Reactjs, Big commerce etc.

1 Comment

Leave a Reply

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