0

I just want to create a global function in laravel 5.1 I create a file in App/Helper.php

Helper.php

 <?php 
    namespace App\Helpers;
    class Helpers {
        public function somethingOrOther()
        {
            return "Yes It is";
        }
}

test.blade.php

Helpers::somethingOrOther();

But it is not working

Every Time I gon a fatel error like "Class 'App\Helpers' not found"

Please Help me

Keval Garala
  • 296
  • 1
  • 5
  • 16

1 Answers1

0

Since you are Helper method are statics you could add your helper class your config/app alias just like a Facade, like so:

'aliases' => [
    //'Helpers'=> 'App\Helpers\Helpers', //for Laravel 5.0
    'Helpers'=> App\Helpers\Helpers::class, //for Laravel 5.1
] 

check this question

What is the best practice to create a custom helper function in php Laravel 5?

Community
  • 1
  • 1
scott
  • 3,112
  • 19
  • 52
  • 90