1 year ago by Jeroen van der Merwe

Relates to the lesson Build a shopping cart

Every time I reload localhost I get:

The localhost page isn’t working

localhost is currently unable to handle this request.


I am currently done with the second episode (Setting Up) and I have gone over my code many times but I can't find the problem! I also checked my error log but what does this mean?

Fatal error: Uncaught DI\DependencyException: Circular dependency detected while trying to resolve entry 'router' in C:\Users\Username\Google Drive\HTML5\Projects\cart\vendor\php-di\php-di\src\DI\Container.php:279 Stack trace:

#0 C:\Users\Username\Google Drive\HTML5\Projects\cart\vendor\php-di\php-di\src\DI\Container.php(122): DI\Container->resolveDefinition(Object(DI\Definition\AliasDefinition))

#1 C:\Users\Username\Google Drive\HTML5\Projects\cart\vendor\php-di\php-di\src\DI\Definition\AliasDefinition.php(63): DI\Container->get('router')

#2 C:\Users\Username\Google Drive\HTML5\Projects\cart\vendor\php-di\php-di\src\DI\Definition\Resolver\SelfResolver.php(34): DI\Definition\AliasDefinition->resolve(Object(DI\Container))

#3 C:\Users\Username\Google Drive\HTML5\Projects\cart\vendor\php-di\php-di\src\DI\Definition\Resolver\ResolverDispatcher.php(58): DI\Definition\Resolver\SelfResolver->resolve(Object(DI\Definition\AliasDefinition), Array)

#4 C:\Users\Username\Google Drive\HTML5\Projects\cart\vendor\php-di\php-di\src\DI\Container.php(2 in C:\Users\Username\Google Drive\HTML5\Projects\cart\vendor\php-di\php-di\src\DI\Container.php on line 279

1 year ago by Ped

[...] A circular dependency between classes A and B will thus both require the definition of A to be placed above B, and the definition of B to be placed above A, which of course is impossible

From: https://en.wikipedia.org/wiki/Circular_dependency

I'm not sure how I can help. Could you show us your router?

Moderator note: I merged your newer topic with this topic. Please, be patient and do not make duplicate posts.

1 year ago by Vince R

I'm having the exact same problem as Jeroen1519. It's at the very end of the video Build a Shopping Cart. Everything works normal and then it's at the very end, the error comes up instead of displaying "This is the homepage".

1 year ago by Thomas Morelli

Best answer

See https://www.codecourse.com/forum/topics/fatal-error-message/4337

It's a problem with php-di/slim-bridge v1.0.3.


  1. Remove php-di/slim-bridge from Composer
  2. Re-require php-di/slim-bridge 1.0.2

Hope this helps :)

1 year ago by Ped

Thanks for your answer, @HiThomasMorelli. I am just going to assume that it works, so I will mark your answer as best.

1 year ago by kishor gujar

Thanks @HiThomasMorelli that worked;

1 year ago by Thomas Morelli

@kishor Glad it helped :)

I got it from here

9 months ago by joy saha

It really helped, thank you.

8 months ago by mehdi

it really helped me right now as well thanks a lot

7 months ago by supervan

Fix for the version problem php-di/slim-bridge v1.0.3.

in Container.php add

use Slim\Interfaces\RouterInterface;

change 'router' => get(Slim\Router::class), to

RouterInterface::class => function (ContainerInterface $container) { return $container->get('router'); },

5 months ago by Sander Voogt

Thanks supervan!

4 days ago by Rob White

Thank you. I can start letting my hair grow back in. Phew! I had a couple of helmet fires trying to resolve this issue. Sometimes the simplest thing is overlooked for more difficult resolutions... hmmm

Sign in or create an account to reply to this topic.