简体   繁体   English

PHP-DI 定义不是由定义数组中的条目名称索引的

[英]PHP-DI definition is not indexed by an entry name in the definition array

I am getting the fatal error below while posting the email and password for JWT Authentication in Slim3 using Postman.使用 Postman 在 Slim3 中发布 JWT 身份验证的电子邮件和密码时,我收到以下致命错误。 How can I solve this?我该如何解决这个问题?

Fatal error: Uncaught Exception: The PHP-DI definition is not indexed by an entry name in the definition array in
C:\new_xampp\htdocs\project\vendor\php-di\php-di\src\Definition\Source\DefinitionArray.php:45

Stack trace:

0 C:\new_xampp\htdocs\project\vendor\php-di\php-di\src\ContainerBuilder.php(148):
DI\Definition\Source\DefinitionArray->__construct(Array, Object(DI\Definition\Source\ReflectionBasedAutowiring))

1 [internal function]: DI\ContainerBuilder->DI{closure}(Array)

2 C:\new_xampp\htdocs\project\vendor\php-di\php-di\src\ContainerBuilder.php(143): array_map(Object(Closure), Array)

3 C:\new_xampp\htdocs\project\public\index.php(33): DI\ContainerBuilder->build()

4 {main}
thrown in C:\new_xampp\htdocs\project\vendor\php-di\php-di\src\Definition\Source\DefinitionArray.php on line45

Maybe a bit late for this, but for anyone facing the exact same error, the problem might be that in the definitions array the index key is missing.可能有点晚了,但对于任何面临完全相同错误的人来说,问题可能是在定义数组中缺少索引键。 eg:例如:

Wrong错误的

$containerBuilder->addDefinitions(array(
  function(Container $container){
     //Code 
  }
));

Correct正确的

$containerBuilder->addDefinitions(array(
  'myAwesomeClass' => function(Container $container){
     //Code 
  }
));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM