Search code examples
laravelsyntax-errorservice-provider

Syntax error on Service Provider


I don't understand why, but I can't get rid of "syntax error, unexpected '::' (T_PAAMAYIM_NEKUDOTAYIM)" after setting a Service Provider. Does anyone have any clue why this is happening?

My ServiceProvider:

namespace Repositories;
use Illuminate\Support\ServiceProvider;
class MainPageServiceProvider extends ServiceProvider {

  public function register()
  {
  $this->app::bind('MainPageInterface', 'MainPagesRepository');
  }

}

Solution

  • It should be:

    $this->app->bind('MainPageInterface', 'MainPagesRepository');
    

    or

    \App::bind('MainPageInterface', 'MainPagesRepository');