當嘗試這樣做,調用我的回購類的任何行動,我得到孩子回購界面上出現以下錯誤:Laravel 4接口文件錯誤:「語法錯誤,意想不到的‘接口’(T_INTERFACE)」
"syntax error, unexpected 'interface' (T_INTERFACE)"
這是錯誤的來源,回購類的代碼,而孩子回購接口文件:
<?php namespace MyProj\Repository\Parent;
use MyProj\Parent;
use MyProj\Parent\ChildRsrc as ChildRsrc;
class EloquentParentRepo implements ParentRepoIfc
{
public $childRepo;
public function __construct(ChildRsrcRepoIfc $childRepo)
{
$this->childRepo = $childRepo;
}
// ...
}
和孩子回購接口文件:
<?php namespace MyProj\Repository\Parent;
interface ChildRscrRepoIfc // the error info points to this line
{
public function all();
public function create($input);
public function delete($id);
public function find($id);
}
它的結構與項目中的其他代碼一樣工作正常。 ChildRsrcRepoIfc及其具體實現(EloquentChildRscrRepo)與此處引用的其他所有內容在同一個父命名空間中。我已經三次檢查拼寫錯誤的拼寫。一如既往,任何幫助表示讚賞。
更新:我想在父類中去除DI和使用直接實例化,但仍然得到了同樣的錯誤:
class EloquentParentRepo implements ParentRepoIfc
{
public function __construct()
{
$this->childRepo = new ChildRsrcRepoIfc;
//...
我仔細檢查了,我做如下的回購SVC提供商綁定:
class RepositoryServiceProvider extends ServiceProvider
{
public function register()
{
$this->app->singleton(
'MyProj\Repository\Parent\ChildRsrcRepoIfc',
'MyProj\Repository\Parent\EloquentChildRsrcRepo'
);
你的'EloquentChildRsrcRepo'在哪裏?你的單身人士正在偷偷摸摸地不存在? –
所有文件位於同一個名稱空間文件夾「MyProj \ Repository \ Parent」中。有許多子表我已經爲其設置了獨立的ChildRsrcNRepoIfc和EloquentChildRsrcNRepo文件。這些子表和它們的回購對應表大多在父項的上下文中引用,所以我以這種方式組織它。 – Bluesail20