Reputation: 1510
I have this error when I used {{ Helper::test(); }}
on a blade
and on my config/app.php
, I already have
and this is inside of my Helper.php
<?php namespace App;
class Helper {
public static function test() {
return "wa";
}
}
and I already done the composer.json
then run the composer dump-autoload
...
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "app/"
},
"files": [
"app/Helper.php"
]
},
...
I don't know what I missed, is there any suggestion to be able to use the helper on a blade on a laravel 5?
Upvotes: 0
Views: 2083
Reputation: 10330
You can do this in two different ways,
First
Remove,
"files": [
"app/Helper.php"
]
from composer.json
and remove
"Helper" =>"App\Helper"
from app.php
and than use like below,
{{ App\Helper::test() }}
Second
keep composer.json
as it is and remove
namespace App;
from Helper.php
than run composer dump-autoload
and use it as below,
{{ Helper::test() }}
Upvotes: 2