Lilamuse
0
Q:

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
0

New to Communities?

Join the community