简体   繁体   English

laravel 5.2中的门面错误

[英]Facade error in laravel 5.2

I installed a package in Laravel 5.2 named jonnywilliamson/laragram 我在Laravel 5.2中安装了一个名为jonnywilliamson / laragram的软件包

And put in config\\app.php a alias and service provider like below : 并在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,
 ]

And in my contoller : 在我的控制器中:

 use TG;

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

And route: 路线:

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

I also run the following commands : 我还运行以下命令:

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

But still shows error like: 但仍显示错误:

 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))

How can i fix it? 我该如何解决?

The function you are trying to call is called sendMessage : 您尝试调用的函数称为sendMessage

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

You are using sendMsg , which is causing the error. 您正在使用sendMsg ,这会导致错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM