【问题标题】:Error on Creating Facade in Laravel 5.3在 Laravel 5.3 中创建外观时出错
【发布时间】:2017-01-23 13:31:58
【问题描述】:

我尝试在 laravel 中创建外观。

我的门面:

 namespace App\Facades;

 use Illuminate\Support\Facades\Facade;

 class someclass_f extends Facade
 {
    protected static function getFacadeAccessor()
    {
      return new \App\Someclass();
    }
 }

我的基类:

  namespace App;

  class Someclass
   {
     public function get($data = [])
      {
        echo "foo";
      }
   }

通话中:

 use App\Facades\someclass_f; 

 class my_class{

    function(){
       someclass_f::get();
    }

 }

我收到错误:

Class 'App\Facades\someclass_f' not found

这是怎么回事?

有什么建议吗?

【问题讨论】:

    标签: php laravel laravel-5.3 laravel-facade


    【解决方案1】:

    你为什么打电话给Someclass::get()?你的门面名称是someclass_f

    将其称为:someclass_f::get();,它将调用 \App\Someclass 中的 get() 函数。

    【讨论】:

    • 对不起,我现在编辑了。这实际上是“someclass_f::get()”。
    猜你喜欢
    • 2019-01-17
    • 2017-05-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-15
    • 2018-11-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多