Monday, March 6, 2017

Facade error in laravel 5.2

I installed a package in Laravel 5.2 named jonnywilliamson/laragram

And put in config\app.php a alias and service provider like below :

 '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?



via Amirali

Advertisement