How to Call a static Method inside a blade in Laravel 5
I have problem. Usually in Laravel 4 I have views / blades that will call static functions from my Helper folder which is located at app/helpers/helper.php.
class Helpers{
public static function myCustomHelper(){
return
"Im a custom helper";
}
I can call it in my blade simple by {{ Helpers::myCustomHelper() }}. However, in Laravel 5 I get an error stating Helpers class is not found.
You'll need to reference the full namespace of Helpers in your template. If it's in the global namespace, you should be able to just prefix it with a backslash: \Helpers:myCustomHelper().
@nolros Tried it but get this error Uncaught exception 'ReflectionException' with message 'Class App\Http\Kernel does not exist' in C:\xampp\htdocs\laravel\storage\framework\compiled.php on line 1026
Fatal error: Uncaught exception 'ReflectionException' with message 'Class App\Http\Kernel does not exist' in C:\xampp\htdocs\laravel\storage\framework\compiled.php on line 1026
Can you declare the same namespace twice? The second reference to App\\ will be overriding the first one, thus breaking references to any of Laravel's default classes.
@drake24 what you were doing was overriding the default application namespace. If you say "everything for the namespace App is in the folder app/libraries/helpers then everything Laravel is trying to load will be missing.