我有一个接口依赖注入问题, 错误消息看起来不能抓住课程, 有什么理想的吗?
错误讯息:
FatalThrowableError in UserController.php line 27:
Class 'App\Http\Controllers\App' not found
我的文件夹路径:
UserController.php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Domain\Services\Social\SocialService;
use Domain\Services\Social\SocialInterface;
use Domain\Services\Social\Facebook;
class UserController extends Controller
{
public function fb(Request $request)
{
App::bind(SocialInterface::class, Facebook::class);
$target = App::make(SocialService::class);
return $target ->getCallbackData($request);
}
}
SocialService.php
namespace Domain\Services\Social;
class SocialService
{
public function getCallbackData(SocialInterface $social,$request)
{
return $social->getCallbackData($request);
}
}
Facebook.php
namespace Domain\Services\Social;
class Facebook implements SocialInterface
{
public function getCallbackData($request)
{
//Somethig inside...
}
}
答案 0 :(得分:0)
public function fb(Request $request)
{
\App::bind(SocialInterface::class, Facebook::class);
$target = \App::make(SocialService::class);
return $target ->getCallbackData($request);
}
使用反斜杠尝试。