0

I have this error when I used {{ Helper::test(); }} on a blade

enter image description here

and on my config/app.php, I already have enter image description here

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?

4

1 回答 1

2

你可以通过两种不同的方式做到这一点,

第一的

消除,

 "files": [
            "app/Helper.php"
        ]

composer.json和删除

"Helper" =>"App\Helper"

app.php和比使用如下,

{{ App\Helper::test() }}

第二

保持composer.json原样并删除

namespace App;

Helper.php比运行composer dump-autoload 和使用它如下,

{{ Helper::test() }}
于 2015-11-26T17:16:22.807 回答