Услуги Symfony2 Круговая зависимость?
ОБНОВЛЕНИЕ: Проблема была не в коде сервера, а в среде выполнения Behat.
Я занимаюсь разработкой проекта Symfony2 и каким-то образом, после многих месяцев разработки, я внес ошибку, которая приводит к сбою всего приложения и выдает следующее сообщение об ошибке:
PHP Fatal error: Maximum function nesting level of '100' reached, aborting! in /var/www/main_api/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Container.php on line 289
PHP Stack trace:
PHP 1. {main}() /home/vagrant/.phpstorm_helpers/behat.php:0
PHP 2. Symfony\Component\Console\Application->run() /home/vagrant/.phpstorm_helpers/behat.php:423
PHP 3. Behat\Testwork\Cli\Application->doRun() /var/www/main_api/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:126
PHP 4. Behat\Testwork\Cli\Application->createCommand() /var/www/main_api/vendor/behat/behat/src/Behat/Testwork/Cli/Application.php:96
PHP 5. Symfony\Component\DependencyInjection\ContainerBuilder->get() /var/www/main_api/vendor/behat/behat/src/Behat/Testwork/Cli/Application.php:138
PHP 6. Symfony\Component\DependencyInjection\ContainerBuilder->createService() /var/www/main_api/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:490
PHP 7. Symfony\Component\DependencyInjection\ContainerBuilder->resolveServices() /var/www/main_api/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:943
PHP 8. array_map() /var/www/main_api/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:1015
PHP 9. Symfony\Component\DependencyInjection\ContainerBuilder->resolveServices() /var/www/main_api/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:1015
PHP 10. array_map() /var/www/main_api/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:1015
PHP 11. Symfony\Component\DependencyInjection\ContainerBuilder->resolveServices() /var/www/main_api/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:1015
PHP 12. Symfony\Component\DependencyInjection\ContainerBuilder->get() /var/www/main_api/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:1017
PHP 13. Symfony\Component\DependencyInjection\ContainerBuilder->createService() /var/www/main_api/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:490
PHP 14. Symfony\Component\DependencyInjection\ContainerBuilder->resolveServices() /var/www/main_api/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:943
PHP 15. array_map() /var/www/main_api/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:1015
PHP 16. Symfony\Component\DependencyInjection\ContainerBuilder->resolveServices() /var/www/main_api/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:1015
PHP 17. Symfony\Component\DependencyInjection\ContainerBuilder->get() /var/www/main_api/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:1017
PHP 18. Symfony\Component\DependencyInjection\ContainerBuilder->createService() /var/www/main_api/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:490
[...]
PHP 93. Symfony\Component\DependencyInjection\ContainerBuilder->get() /var/www/main_api/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:1017
PHP 94. Symfony\Component\DependencyInjection\ContainerBuilder->createService() /var/www/main_api/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:490
PHP 95. Symfony\Component\DependencyInjection\ContainerBuilder->resolveServices() /var/www/main_api/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:943
PHP 96. array_map() /var/www/main_api/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:1015
PHP 97. Symfony\Component\DependencyInjection\ContainerBuilder->resolveServices() /var/www/main_api/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:1015
PHP 98. Symfony\Component\DependencyInjection\ContainerBuilder->get() /var/www/main_api/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:1017
PHP 99. Symfony\Component\DependencyInjection\Container->get() /var/www/main_api/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:469
Fatal error: Maximum function nesting level of '100' reached, aborting! in /var/www/main_api/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Container.php on line 289
Call Stack:
0.0010 412904 1. {main}() /home/vagrant/.phpstorm_helpers/behat.php:0
0.4579 3401528 2. Symfony\Component\Console\Application->run() /home/vagrant/.phpstorm_helpers/behat.php:423
0.4900 3747408 3. Behat\Testwork\Cli\Application->doRun() /var/www/main_api/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:126
0.4900 3747392 4. Behat\Testwork\Cli\Application->createCommand() /var/www/main_api/vendor/behat/behat/src/Behat/Testwork/Cli/Application.php:96
1.7987 7874496 5. Symfony\Component\DependencyInjection\ContainerBuilder->get() /var/www/main_api/vendor/behat/behat/src/Behat/Testwork/Cli/Application.php:138
1.7987 7876432 6. Symfony\Component\DependencyInjection\ContainerBuilder->createService() /var/www/main_api/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:490
1.7991 7879072 7. Symfony\Component\DependencyInjection\ContainerBuilder->resolveServices() /var/www/main_api/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:943
1.7991 7879560 8. array_map() /var/www/main_api/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:1015
1.7991 7880392 9. Symfony\Component\DependencyInjection\ContainerBuilder->resolveServices() /var/www/main_api/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:1015
1.7991 7880880 10. array_map() /var/www/main_api/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:1015
3.0948 14305112 11. Symfony\Component\DependencyInjection\ContainerBuilder->resolveServices() /var/www/main_api/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:1015
3.0948 14305200 12. Symfony\Component\DependencyInjection\ContainerBuilder->get() /var/www/main_api/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:1017
3.0948 14305496 13. Symfony\Component\DependencyInjection\ContainerBuilder->createService() /var/www/main_api/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:490
3.0949 14306208 14. Symfony\Component\DependencyInjection\ContainerBuilder->resolveServices() /var/www/main_api/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:943
3.0949 14306696 15. array_map() /var/www/main_api/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:1015
3.1179 14383304 16. Symfony\Component\DependencyInjection\ContainerBuilder->resolveServices() /var/www/main_api/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:1015
3.1179 14383416 17. Symfony\Component\DependencyInjection\ContainerBuilder->get() /var/www/main_api/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:1017
3.1180 14383760 18. Symfony\Component\DependencyInjection\ContainerBuilder->createService() /var/www/main_api/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:490
[...]
3.1192 14540512 79. Symfony\Component\DependencyInjection\ContainerBuilder->createService() /var/www/main_api/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:490
3.1193 14540952 80. Symfony\Component\DependencyInjection\ContainerBuilder->resolveServices() /var/www/main_api/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:943
3.1193 14541440 81. array_map() /var/www/main_api/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:1015
3.1193 14542096 82. Symfony\Component\DependencyInjection\ContainerBuilder->resolveServices() /var/www/main_api/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:1015
3.1193 14542144 83. Symfony\Component\DependencyInjection\ContainerBuilder->createService() /var/www/main_api/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:1019
3.1193 14542584 84. Symfony\Component\DependencyInjection\ContainerBuilder->resolveServices() /var/www/main_api/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:943
3.1193 14543072 85. array_map() /var/www/main_api/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:1015
3.1193 14543728 86. Symfony\Component\DependencyInjection\ContainerBuilder->resolveServices() /var/www/main_api/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:1015
3.1193 14543816 87. Symfony\Component\DependencyInjection\ContainerBuilder->get() /var/www/main_api/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:1017
3.1194 14544112 88. Symfony\Component\DependencyInjection\ContainerBuilder->createService() /var/www/main_api/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:490
3.1244 14552552 89. Symfony\Component\DependencyInjection\ContainerBuilder->callMethod() /var/www/main_api/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:975
3.1244 14553384 90. Symfony\Component\DependencyInjection\ContainerBuilder->resolveServices() /var/www/main_api/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:1165
3.1244 14553872 91. array_map() /var/www/main_api/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:1015
3.1244 14554464 92. Symfony\Component\DependencyInjection\ContainerBuilder->resolveServices() /var/www/main_api/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:1015
3.1244 14554568 93. Symfony\Component\DependencyInjection\ContainerBuilder->get() /var/www/main_api/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:1017
3.1245 14554896 94. Symfony\Component\DependencyInjection\ContainerBuilder->createService() /var/www/main_api/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:490
3.1246 14555512 95. Symfony\Component\DependencyInjection\ContainerBuilder->resolveServices() /var/www/main_api/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:943
3.1246 14556000 96. array_map() /var/www/main_api/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:1015
3.1247 14557184 97. Symfony\Component\DependencyInjection\ContainerBuilder->resolveServices() /var/www/main_api/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:1015
3.1247 14557280 98. Symfony\Component\DependencyInjection\ContainerBuilder->get() /var/www/main_api/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:1017
3.1247 14557424 99. Symfony\Component\DependencyInjection\Container->get() /var/www/main_api/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:469
Process finished with exit code 255
Я думаю, что это потому, что круговая зависимость между службами, это возможно? Если это так, существует ли систематический способ поиска циклических зависимостей между службами в Symfony?
1 ответ
В конце концов, это была не проблема в моем коде, а в среде исполнения Behat.
Мне пришлось изменить максимальный уровень вложенности с помощью следующей записи в /etc/php5/cli/php.ini
файл (я нахожусь на Debian):
[XDebug]
xdebug.max_nesting_level = 1000