Laravel

How to create helper file in laravel?

Create helper file in laravel

Views

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/Helper.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

Ajay Malhotra
the authorAjay Malhotra
Hello to all. Welcome to therichpost.com. Myself Ajay Malhotra and I am full stack developer. I love coding. I know Wordpress, Core php, Angularjs, Angular 2, Angular 6, Angular 7, laravel, Codeigniter, Shopify, Squarespace, Jquery, Google Map Api, Vuejs, Reactjs, Bigcommerce etc.

Leave a Reply

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

Positive SSL