我在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))
我该如何解决?
答案 0 :(得分:0)
您尝试呼叫的功能称为sendMessage
:
return TG::sendMessage('+989118000000', 'Hello there!');
您正在使用导致错误的sendMsg
。