You have a cycle in your dependency graph:
UserRepo -> CartRepo -> ItemRepo -> UserRepo -> …
You can't resolve that. It's an infinite loop, xdebug.max_nesting_level
won't help you.
I'm just surprised that Laravel DI container doesn't throw an explicit exception.
You have to rethink your dependencies between services/repositories, maybe by splitting some classes into smaller, less coupled objects.
Update: Woops, I forgot about a couple of solutions!
- Setter injection
Rather than injecting a dependency in the constructor, you can have it injected in a setter, which would be called after the object is constructed. In pseudo-code, that would look like that:
$userRepo = new UserRepository();
$cartRepo = new CartRepository($userRepo);
$userRepo->setCartRepo($userRepo);
- Lazy injection
I don't know if Laravel does support lazy injection, but that's also a solution: the container will inject a proxy object instead of the actual dependency. That proxy-object will load the dependency only when it is accessed, thus removing the need to build the dependency when the constructor is called.