gothinkster / slim-php-realworld-example-app

Exemplary real world application built with Slim
https://realworld.io
427 stars 96 forks source link

Instance of Slim\Container where Interop\Container\ContainerInterface was given #21

Open kacperaniolek opened 4 years ago

kacperaniolek commented 4 years ago

Running the fresh checkout of the repository (tuned docker-compose.yml though) in Docker throws TypeError:

www_1         | [Mon Mar 16 18:52:25 2020] 172.21.0.1:55822 [200]: GET / - Uncaught TypeError: Argument 1 passed to Conduit\Middleware\OptionalAuth::__construct() must be an instance of Interop\Container\ContainerInterface, instance of Slim\Container given, called in /var/www/src/dependencies.php on line 48 and defined in /var/www/src/Conduit/Middleware/OptionalAuth.php:23
www_1         | Stack trace:
www_1         | #0 /var/www/src/dependencies.php(48): Conduit\Middleware\OptionalAuth->__construct(Object(Slim\Container))
www_1         | #1 /var/www/vendor/pimple/pimple/src/Pimple/Container.php(118): {closure}(Object(Slim\Container))
www_1         | #2 /var/www/vendor/slim/slim/Slim/Container.php(109): Pimple\Container->offsetGet('optionalAuth')
www_1         | #3 /var/www/src/routes.php(20): Slim\Container->get('optionalAuth')
www_1         | #4 /var/www/vendor/slim/slim/Slim/RouteGroup.php(25): Closure->{closure}(Object(Slim\App))
www_1         | #5 /var/www/vendor/slim/slim/Slim/App.php(272): Slim\RouteGroup->__invoke(Object(Slim\App))
www_1         | #6 /var/www/src/routes.php(83): Slim\App->group('/api', Object(Closure))
www_1         | #7 /var/www/public/index.php(27): require('/var/www/src/ro...')
www_1         | #8 {main}
www_1         |   thrown in /var/www/src/Conduit/Middleware/OptionalAuth.php on line 23

Since container-interop/container-interop is deprecated, I gave switching to Psr\Container\ContainerInterface a try and it seems to work for now.

I am using WSL2 on Windows 10 and Docker Desktop. I executed composer install beforehand.

rivetmichael commented 3 years ago

I have the same error, just after executing composer install

rafsanjani94 commented 2 years ago

I have the same error too, just after executing composer install