【问题标题】:Facade error in laravel 5.2laravel 5.2中的外观错误
【发布时间】:2017-03-05 14:44:56
【问题描述】:

我在 Laravel 5.2 中安装了一个名为 jonnywilliamson/laragram 的包

并输入config\app.php 别名和服务提供商,如下所示:

 'providers' => [
    .
    .
    .,
    Illuminate\Translation\TranslationServiceProvider::class,
    Illuminate\Validation\ValidationServiceProvider::class,
    Illuminate\View\ViewServiceProvider::class,
    Williamson\Laragram\Laravel\LaragramServiceProvider::class,
 ]


 'aliases' => [
    .
    .
    .,
    'URL' => Illuminate\Support\Facades\URL::class,
    'Validator' => Illuminate\Support\Facades\Validator::class,
    'View' => Illuminate\Support\Facades\View::class,
    'TG' => Williamson\Laragram\Laravel\LaragramFacade::class,
 ]

在我的控制器中:

 use TG;

 public function test()
 {
  return TG::sendMsg('+989118000000', 'Hello there!');
 }

还有路线:

Route::get('test', 'Services\Auth\Controller\v1_0\AuthController@test');

我还运行以下命令:

   composer dumpautoload 
   composer dumpautoload -o 
   php artisan cache:clear 
   php artisan clear-compiled
   php artisan optimize

但仍然显示如下错误:

 RuntimeException in Facade.php line 210:
 A facade root has not been set.
 in Facade.php line 210

 at Facade::__callStatic('sendMsg', array('+989118000217', 'Hello there!')) in User.php line 68
 at LaragramFacade::sendMsg('+989118000217', 'Hello there!') in User.php line 68
 at AuthController->test('fa')
 at call_user_func_array(array(object(AuthController), 'test'), array('lang' => 'fa')) in Controller.php line 80
 at Controller->callAction('test', array('lang' => 'fa')) in ControllerDispatcher.php line 146
 at ControllerDispatcher->call(object(AuthController), object(Route), 'test') in ControllerDispatcher.php line 94
 at ControllerDispatcher->Illuminate\Routing\{closure}(object(Request))

我该如何解决?

【问题讨论】:

  • 你可以尝试使用完整的命名空间use Williamson\Laragram\Laravel\LaragramFacade as TG而不是别名TG
  • 还是一样的错误:(
  • 请朋友们帮帮我:(这很重要
  • 嘿,你更新config/services.php了吗?

标签: php laravel laravel-5.2 laravel-facade


【解决方案1】:

您尝试调用的函数称为sendMessage

return TG::sendMessage('+989118000000', 'Hello there!');

您正在使用sendMsg,这是导致错误的原因。

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2016-06-18
  • 2016-09-07
  • 1970-01-01
  • 2020-06-02
  • 2016-04-25
  • 1970-01-01
  • 2016-03-28
  • 2016-06-11
相关资源
最近更新 更多