Class 'Helper' not found in laravel code example

Example: error class helper not found laravel

Step 1: Create your Helpers (or other custom class) file and give it a matching
namespace. Write your class and method:

<?php // Code within app\Helpers\Helper.php

namespace App\Helpers;

class Helper
{
    public static function shout(string $string)
    {
        return strtoupper($string);
    }
}
-----------------------------------------

Step 2: Code within config/app.php
  
<?php
    'aliases' => [
     ...
        'Helper' => App\Helpers\Helper::class,
     ...

---------------------------------------------
  
Step 3:
  
<!-- Code where you want to use Helper class -->

{!! Helper::shout('this is how to use autoloading correctly!!') !!}

reference :
  https://stackoverflow.com/questions/28290332/best-practices-for-custom-helpers-in-laravel-5

Tags:

Php Example