Skip to content

Frequently Encountered Errors

Ahmad Altaher Alfayad edited this page Apr 30, 2024 · 4 revisions

Changing Controller Code and Route Not Found

During your stint of development on UDOIT, you will inevitably have to either change some code relating to an existing controller or add a new controller for some specific purpose. Upon doing either of those things, you will inevitably run into an error where your changes are either not registered, the dependency which you have injected is not recognized, or the newly added controller itself is not accessible. The solution for this issue is to clear the cache that Symfony sets up when you run your instance of UDOIT. If you are using Docker to run UDOIT, then simply run your database image, cd into your UDOIT repository, and run the following command in your terminal:

docker-compose -f docker-compose.nginx.yml run php bin/console cache:clear

Fatal error: Declaration of Container[some string]\EntityManager_[some string]::refresh($entity) must be compatible...

Sometimes, your application will not run because a cache container might not be up to date with some newer packages that you have installed using composer. To fix this issue, simply go into the var/cache/prod folder and delete the container that is giving you trouble (an example name for a container is ContainerQBhi7Mt). Don't worry about deleting it as an updated container will sprout back out with the updated code.

Printing out content to the terminal

Printing out content to the terminal using Symfony is shockingly not that straightforward. One way that we found to work would be to use the ConsoleOutput object. To do that, import ConsoleOutput using Symfony\Component\Console\Output\ConsoleOutput and instantiate a new instance of the object by typing $output = new ConsoleOutput(); in your function. Print information using the $output->writeln() method.