Symfony ServiceCircularReferenceException. What to do?

The project has just started, for 99% of code is generated by command "composer create-project symfony/framework-standard-edition my_project_name". A few days ago left the development, there were other things, now returned and were surprised to find that he ceased to run (access to the code only I have no one else to get in could not).

Throws this error:
Circular reference detected for service "AppBundle\Exception\HttpException\ValidationHttpException", path: "AppBundle\Exception\HttpException\ValidationHttpException -> AppBundle\Exception\HttpException\ValidationHttpException".

The problem is that such a service is not, and never was. This is stupid the usual eksepsi, emitted once in the controller instance which is not created (error thrown before). Search by code also results was not given. I tried the yml configs to remove all except the default - did not help.

If the class is remove, then the error disappears and everything works again. But damn it, I need it, and voobche want to understand where this crap happens. Nobody faced? What could it be?
June 10th 19 at 14:42
2 answers
June 10th 19 at 14:44
Solution
Perhaps you have a crooked configured of autowiring and auto-configuration of the services and for some reason, the exception is logged as a service.
Perhaps, but how to understand and fix, even if resetting to default doesn't help. I tried Vardapet all the variables in the call chain, but the data structure there's a huge and such picking out an inadequate amount of time. - Cassandre_Boy commented on June 10th 19 at 14:47
, Stampede a container view which services are registered. In the end you can just see in the compiled container and look for the class name. - Justice.Nienow commented on June 10th 19 at 14:50
sorry to run any console commands, including the debug:container, prevents the same error. And debug:autowiring is not fitted, the installation instructions I naguglit failed.

Interesting observation - I've renamed the class (and file) in ValidationHttpException111 and error then these ones appeared.

If the class to remove the command works, but no mention about this class is no longer there. - Cassandre_Boy commented on June 10th 19 at 14:53
The elimination method found the cause, it was in the file app/config/services.yml in the line
AppBundle\:
 resource: '../../src/AppBundle/*'
 # you can exclude directories or files
 # but if a service is unused, it's removed anyway
 exclude: '../../src/AppBundle/{Entity,Repository,Tests}'


I added a folder in the exclude folder AppBundle/Exception and the problem disappeared.

Although still weird, in another project I have the same acceptn and similar problems arose.

PS. In General, the possible situation in which acceps may be required in the form of service? Something it's hard to imagine this was the case. - Cassandre_Boy commented on June 10th 19 at 14:56
, That's what I had in mind when he wrote:
and for some reason, the exception is logged as a service


In General, the possible situation in which acceps may be required in the form of service? Something it's hard to imagine this was the case.

Unlikely. But that does not mean that the framework should forbid you from doing. - Justice.Nienow commented on June 10th 19 at 14:59
Yes, but unfortunately I never found a specific reason why the framework decided to register as a service, this is the class. And my decision is in fact a crutch, I just stoped the problem but not solved it. - Cassandre_Boy commented on June 10th 19 at 15:02
And what's wrong with it?
resource: '../../src/AppBundle/*'
There is clearly stated: "take everything in here and do the service." It is logical to exclude only that they should not be. - Justice.Nienow commented on June 10th 19 at 15:05
I certainly badly understand what that setting is, earlier somehow did not pay attention.

But when a previously created their services - I had to register them separately, giving them a name, specifying the class, constructor arguments, call methods, etc. And only then I was able to pull the service from the container. So that itself was trying to register for the first time see, although litter folder AppBundle like I never shy)) - Cassandre_Boy commented on June 10th 19 at 15:08
You seem to not have followed the third branch of Symfony.
Read here: https://symfony.com/doc/current/service_container/... - Justice.Nienow commented on June 10th 19 at 15:11
June 10th 19 at 14:46
Maybe you can be corny to the constructor of the same class are asking?

Find more questions by tags Symfony