Symfony InvalidArgumentException when running app/console

懵懂的女人 提交于 2019-12-11 11:59:10

问题


I have been developing a website using Symfony. Everything was good until earlier today I was adding some Fixtures using the DoctrineFixturesBundle and ran the "app/console" command. I received the following error:

[Symfony\Component\DependencyInjection\Exception\InvalidArgumentException]
 Symfony\\Bundle\\AsseticBundle\\EventListener\\RequestListener
 is not a valid class name for the "assetic.request_listener" service.

I tried undoing the changes I made to the fixtures to find my mistake and it didn't change. In my infinite wisdom, I decided to try updating my vendors by running "composer update" and it didn't work.

Also, when I run my site in a browser, I get the same error.

I don't know what's going on. Someone please help, any help appreciated.


回答1:


For those who stop by :)

In most cases problem is with class name which has leading \ in front of class name. More info more info




回答2:


Just wanted to let you all know how I fixed it. It's not the most elegant solution but it worked. I downloaded a new company of Symfony, copied over all my bundles, my whole config directory,my composer.json, and my AppKernel.php. It got rid of all my errors, even some cache issues I was getting.




回答3:


For the record, this error is always related to one thing and that's the name of the class is wrong. Either you are specifying the path the class incorrectly, or you spelled the name wrong.

For instance, I got stumped on this one because I accidentally add .php to the class name.




回答4:


Reformat on .xml files gave me same issue. Exactly, reformat the files in a directory instead of a single file, working with PhpStorm.

@abarisone: Problem was in a services.xml file. PhpStorm "reformat" transform (example):

    <parameter key="xxx">Petrus\xx\xx\XHRCoreExceptionListener</parameter>

to:

    <parameter key="xxx">
        Petrus\xx\xx\XHRCoreExceptionListener
    </parameter>

Was hard to find and easy to correct, manually with help of "Local history" Phpstorm's feature.



来源:https://stackoverflow.com/questions/17330422/symfony-invalidargumentexception-when-running-app-console

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!