1Step 1: Create your Helpers (or other custom class) file and give it a matching
2namespace. Write your class and method:
3
4<?php // Code within app\Helpers\Helper.php
5
6namespace App\Helpers;
7
8class Helper
9{
10 public static function shout(string $string)
11 {
12 return strtoupper($string);
13 }
14}
15-----------------------------------------
16
17Step 2: Code within config/app.php
18
19<?php
20 'aliases' => [
21 ...
22 'Helper' => App\Helpers\Helper::class,
23 ...
24
25---------------------------------------------
26
27Step 3:
28
29<!-- Code where you want to use Helper class -->
30
31{!! Helper::shout('this is how to use autoloading correctly!!') !!}
32
33reference :
34 https://stackoverflow.com/questions/28290332/best-practices-for-custom-helpers-in-laravel-5