Answer the question
In order to leave comments, you need to log in
Why an error when creating a new route?
There is a project that needs to be changed. When creating a new controller, according to the existing namespace, the following error occurs
Fatal error: Uncaught Symfony\Component\DependencyInjection\Exception\InvalidArgumentException: Expected to find class "App\Controller\MyController" in file "/var/www/app/src/Controller/MyController.php" while importing services from resource ". ./src/*", but it was not found! Check the namespace prefix used with the resource.
MyController.phpdoes not see, but
TestController.phpsees (the contents of the files are the same except for the names of the classes corresponding to the names of the files).
found a solution and it is painfully strange.
I created controllers all by hand (I wrote the names of files and classes myself, not copy-paste). One controller accepts, the other does not.
At random, I found out that when creating a controller that it accepts, you need to run any route, if there is a cache error, then run it again.
Then I change the name of the file and class. I launch any route.
I add one method at a time and after each I start the route ...
All other changes are made using this method.
He swore only at controllers and services, he accepted entities and repositories right away.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question