0

After using a ServiceProvider, Laravel give me an Error 500... If I remove the :

I know, there's no need of binding because there's no DI, I am experiencing...

GameController :

namespace App\Http\Controllers\Game;

use App;
use App\Http\Controllers\Controller;

class GameController extends Controller
{
    public function start(GameRepositoryInterface $gameRepository) {
        return $gameRepository->getLastAdd();
    }
}

GameServiceProvider :

namespace App\Providers\Game;

use Illuminate\Support\ServiceProvider;
use App\Http\Controllers\Game\StdGameRepository;
use App\Http\Controllers\Game\GameRepositoryInterface;

class GameServiceProvider extends ServiceProvider
{
    protected $defer = true;

    public function register() {
        dd('ici');
        $this->app->bind(StdGameRepository::class, function() {
           return new StdGameRepository();
        });

        $this->app->bind(GameRepositoryInterface::class, StdGameRepository::class);
    }

    public function provides() {
        return [GameRepositoryInterface::class];
    }
}

GameRepositoryInterface :

namespace App\Http\Controllers\Game;

interface GameRepositoryInterface
{
    public function getLastAdd();
}

StdGameRepository :

namespace App\Http\Controllers\Game;

class StdGameRepository implements GameRepositoryInterface
{
    private $lastAdd = "Testing";

    public function getLastAdd()
    {
        return $this->lastAdd;
    }
}
Neok
  • 221
  • 2
  • 17
  • What was the error? – Rwd Mar 05 '17 at 18:12
  • I try to get more information but all i got is "GET http://localhost/~macbook/projects/laravel/start 500 (Internal Server Error)"... I set env('APP_DEBUG', true) and modify the php.ini but I can't get more... – Neok Mar 05 '17 at 18:17
  • Check your log file. `storage/logs/laravel.log`. Also what version of Laravel are you using? – Rwd Mar 05 '17 at 18:21
  • I'm on Laravel Framework 5.4.14, and the last thing in laravel.log is from [2017-03-04 18:20:24]... – Neok Mar 05 '17 at 18:27
  • It probably isn't the case at all but for the sake of it you could try changing `\App\...` to `App\...` in your providers array. – Rwd Mar 05 '17 at 18:29
  • Thanks, I just change that, and the error now show up when i use the class which need the SP, any idea ? (I edit the post with the code of the controller using it) – Neok Mar 05 '17 at 18:34

0 Answers0