[英]Target Interface is not instantiable. Laravel 4
When I search the error 'Target Interface is not instantiable' I get a lot of results. 当我搜索错误“目标接口不可实例化”时,我得到了很多结果。 Somehow I can still not find the solution to my problem. 我仍然无法以某种方式找到解决问题的方法。
I am not sure where it goes wrong. 我不确定哪里出了问题。
PartnerController.php PartnerController.php
<?php use CmsBlox\MOD\PartnerInterface;
class PartnerController extends BaseController {
public function __construct(PartnerInterface $partner)
{
$this->partner = $partner;
}
public function Get()
{
return "I'm the Get function in class PartnerController";
}
}
PartnerServiceProvider.php PartnerServiceProvider.php
<?php namespace CmsBlox\Providers;
use App, Illuminate\Support\ServiceProvider;
class PartnerServiceProvider extends ServiceProvider {
public function register()
{
}
public function boot()
{
app::bind('CmsBlox\MOD\PartnerInterface') ;
}
}
Routes.php routes.php文件
app::bind('CmsBlox\MOD\PartnerInterface') ;
PartnerInterface.php PartnerInterface.php
<?php namespace CmsBlox\MOD;
interface PartnerInterface {
public function get();
}
I have also added the provider to App.php (for testing also a app::bind() in the routes.php) 我还已将提供程序添加到App.php中(用于在routes.php中测试一个app :: bind())
'CmsBlox\Providers\PartnerServiceProvider'
As far I know every file should be correct. 据我所知,每个文件都应该正确。 Somehow I am missing something! 我不知何故想念什么!
I just found the answer! 我才找到答案! Thanks to the Laravel.io forums. 感谢Laravel.io论坛。
<?php use CmsBlox\MOD\PartnerInterface;
class PartnerController extends BaseController implements PartnerInterface {
public function get() {...}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.