Closed noromamai closed 2 years ago
The DI container definitions are looking good. I guess there are something in the bootstrap that should be checked. Can you show your bootstrap.php file? Also search for other parts where you try to create a Slim App instance.
this is the contents of bootstrap.php
<?php
use App\Factory\ContainerFactory;
use Slim\App;
require_once __DIR__ . '/../vendor/autoload.php';
// Build DI Container instance
$container = (new ContainerFactory())->createInstance();
// Create App instance
return $container->get(App::class);
Ok, now I see it. There are two DI definitions for ResponseFactoryInterface::class
.
Please try to remove this DI definition. This causes the circular dependency failure because the Slim AppFactory tries to fetch the ResponseFactory before the App instance exists.
ResponseFactoryInterface::class => function (ContainerInterface $container) {
return $container->get(App::class)->getResponseFactory();
},
Thanks for the help so far.
after commenting out that DI definition I no longer get that error. When using an incorrect username/password combination i get the expected 401 Unauthorized. But (still using your example code) when i use "user"/"secret" as in your example, i get an 500 error and nothing in the logs.
It seems to go wrong here in src/Routing/JwtAuth.php:
// Builds a new token using the private key
return $builder->getToken(
$this->configuration->signer(),
$this->configuration->signingKey()
)->toString();
if i echo something before i can still see it in Postman, if i echo something afterwards i get nothing.
To display more details, you can try to enable the error details and logging in the settings. Also, Xdebug is a useful helper.
$settings['error']['display_error_details'] = true;
$settings['error']['log_errors'] = true;
error_reporting(E_ALL);
ini_set('display_errors', '1');
ini_set('display_startup_errors', '1');
working! it was a stupid permission issue, very sorry about that. after turning on logging (php error logging was already turned on) i got an error about not being able to writ eto the error log. been working on two things at the same time and though i had already chown'ed it, but as it turns out it wasn't. sorry for bothering due to such a stupid mistake, but am very grateful and appreciate the great support.
Hi,
I set up the slim 4 framework following your ebook, but then ran into some issues with composer. After that I just took your slmi4-framwork from github and got it up and running. After that I followed the JWT part in your ebook but can't get it to work. I end up with a "Uncaught DI\DependencyException: Circular dependency detected while trying to resolve entry 'Slim\App'" error. Any help getting this solved would be greatly appreciated.
The error as i get it in postman when testing:
contents of config/container.php: