Bluesail20
Bluesail20

Reputation: 319

Laravel 4 interface file error: "syntax error, unexpected 'interface' (T_INTERFACE)"

When trying to do any actions that invoke my Repo class, I get the following error on the child Repo interface:

"syntax error, unexpected 'interface' (T_INTERFACE)"

Here is the code for the Repo class, and the child repo interface file that is the source of the error:

<?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;
    }
    // ...
    }

and the child repo interface file:

<?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);
}

It all is structured just like other code in the project that works fine. The ChildRsrcRepoIfc and its concrete implementation (EloquentChildRscrRepo) are in the same Parent namespace as everything else referenced here. I've triple-checked all spelling for typos. Any help is appreciated, as always.

Update: I tried removing the DI in the parent class and using direct instantiation but still got the same error:

class EloquentParentRepo implements ParentRepoIfc 
{
    public function __construct()
    {
        $this->childRepo = new ChildRsrcRepoIfc;
  //...

And I double checked that I am doing the binding in the Repo Svc Provider as follows:

class RepositoryServiceProvider extends ServiceProvider 
{
    public function register()
    {
     $this->app->singleton(
       'MyProj\Repository\Parent\ChildRsrcRepoIfc',
       'MyProj\Repository\Parent\EloquentChildRsrcRepo'
     ); 

Upvotes: 1

Views: 3179

Answers (1)

Antonio Carlos Ribeiro
Antonio Carlos Ribeiro

Reputation: 87719

Shouldn't this be?:

class RepositoryServiceProvider extends ServiceProvider 
{
    public function register()
    {
     $this->app->singleton(
       'MyProj\Repository\Parent\ChildRsrcRepoIfc',
       'MyProj\Repository\Parent\EloquentParentRepo '
     ); 

Something that happened to me once while using Laravel IoC automatic resolution was writing

<?

Instead of

<?php

Laravel cannot find the file if you do this. Check your files.

Upvotes: 2

Related Questions