簡體   English   中英

laravel 5.2中的門面錯誤

[英]Facade error in laravel 5.2

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

我該如何解決?

您嘗試調用的函數稱為sendMessage

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

您正在使用sendMsg ,這會導致錯誤。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM