Description
I get the following error when I add TwigBundle to the AppKernel:
PHP Fatal error: Maximum function nesting level of '100' reached, aborting! in /vagrant/www/symfony-rest-edition/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Compiler/AnalyzeServiceReferencesPass.php on line 96
I rebuilt my setup here based on the Symfony2 Rest Edition as my system uses nearly the same components: https://github.com/motain/symfony-rest-edition
I originally developed an API in this system and disabled Twig support when I started developing it. So I set the templating engine to php in the config.yml.
After some time of developing I wanted to add the TwigBundle again to make use of the ExceptionController from the FOSRestBundle: https://github.com/FriendsOfSymfony/FOSRestBundle/blob/master/Resources/doc/4-exception-controller-support.md#step-4-exceptioncontroller-support
So I added the TwigBundle to the AppKernel again. In dev environment everything worked fine but when clearing the cache with prod environment I got the described error (PHP Fatal error: Maximum function nesting level of '100' reached, aborting! in /vagrant/www/symfony-rest-edition/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Compiler/AnalyzeServiceReferencesPass.php on line 96). To reproduce this just start:
./app/api/console --env=prod
with a cleared cache (Note: I put my app directory under a separate subdirectory to fully simulate my original working environment which I can not make public).
After nearly 2 days debugging now I noticed that changing the config entry of framework.templating back to twig solved the problem. But anyway I think it is an issue to look at.