Create Custom helper Functions in Laravel

Today, We want to share with you Create Custom helper Functions in Laravel.In this post we will show you how to use helper function in laravel, hear for Laravel Custom Helper Functions Fil we will give you demo and example for implement.In this post, we will learn about Laravel 5.8 – Custom Helper Facade Class Example from scratch with an example.

Create Custom helper Functions in Laravel

There are the Following The simple About Create Custom helper Functions in Laravel Full Information With Example and source code.

Free Live Chat for Any Issue

As I will cover this Post with live Working example to develop laravel 5.8 custom helper functions, so the add custom helpers in laravel 5.8 for this example is following below.

Also Read This πŸ‘‰   Woocommerce get price in custom loop

Create a Laravel Helper Functions


namespace App\Libraries;
class General {
// Laravel 5.8 function to fetch simple gravatar Your Profile photo/image from Main Website Like Name is a using email id.
  public static function getGravatarURL($email, $s = 80, $d = 'mm', $r = 'g', $img = false, $resData = array())
    $live_url = '';
    $live_url .= md5(strtolower(trim($email)));
    $live_url .= "?s=$s&d=$d&r=$r";
    if ($img)
        $live_url = '<img src="' . $live_url . '"';
        foreach ($resData as $key => $val)
            $live_url .= ' ' . $key . '="' . $val . '"';
        $live_url .= ' />';
    return $live_url;

Step 2: Add composer.json Files

Include Simple File Path In composer.json to dump data o the autoloader

"autoload": {
    "files": [

Step 3: Composer in Laravel

Run Composer with Following command

Also Read This πŸ‘‰   Create Different CSS Geometric Shapes with Example

Simple Laravel Functions to run this command to dump the autoloader Automatically.

composer dump-autoload

Simple custom helper in Laravel 5.8

Route::get('/', function(){
    $my_profile_img='<img src="'.General::getGravatarURL('[email protected]').'">';
    echo $my_profile_img;   

Angular 6 CRUD Operations Application Tutorials

Read :


You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about Create Custom helper Functions in Laravel.
I would like to have feedback on my blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Rate this post