Sometimes the simple stuff seems the hardest.
In my case I am working through the Symfony 4 update to the Symfony Deployment course and somewhat unusually, am not doing anything in dev, but lots of stuff in prod.
The reason for this is that I have forked the official Symfony demo project, and have slightly modified it for my needs. As it’s an official demo project, it’s pretty much guaranteed to work.
I had a production server set up, and had deployed my code.
I’d set up my environment variables – I believed, correctly. But when I hit the site:
“Authentication request could not be processed due to a system problem.”
I do enjoy a good error message.
The fix was simple in my case. I had set the wrong path to the database:
DATABASE_URL=mysql://dbuser:dbpassword@127.0.0.1:3306/db_dev
And what it should have been:
DATABASE_URL=mysql://dbuser:dbpassword@127.0.0.1:3306/dev_db
The db name was back to front.
In prod, the log files give no help around this, at all.
I had to spin up the dev environment where things are a lot more evident:
[2018-01-12 12:50:22] request.INFO: Matched route "security_login". {"route":"security_login","route_parameters":{"_controller":"App\\Controller\\SecurityController::login","_locale":"en","_route":"security_login"},"request_uri":"http://127.0.0.1:8000/en/login","method":"POST"} [] [2018-01-12 12:50:22] security.INFO: Authentication request failed. {"exception":"[object] (Symfony\\Component\\Security\\Core\\Exception\\AuthenticationServiceException(code: 0): An exception occurred in driver: SQLSTATE[HY000] [1044] Access denied for user 'dbuser'@'%' to database 'dev_db' at /tmp/symfony-4-demo-app/vendor/symfony/security/Core/Authentication/Provider/DaoAuthenticationProvider.php:85, Doctrine\\DBAL\\Exception\\ConnectionException(code: 0): An exception occurred in driver: SQLSTATE[HY000] [1044] Access denied for user 'dbuser'@'%' to database 'dev_db' at /tmp/symfony-4-demo-app/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php:108, Doctrine\\DBAL\\Driver\\PDOException(code: 1044): SQLSTATE[HY000] [1044] Access denied for user 'dbuser'@'%' to database 'dev_db' at /tmp/symfony-4-demo-app/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:47, PDOException(code: 1044): SQLSTATE[HY000] [1044] Access denied for user 'dbuser'@'%' to database 'dev_db' at /tmp/symfony-4-demo-app/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:43)"} [] [2018-01-12 12:50:22] security.DEBUG: Authentication failure, redirect triggered. {"failure_path":"security_login"} [] [2018-01-12 12:50:22] request.INFO: Matched route "security_login". {"route":"security_login","route_parameters":{"_contr
The give away line being:
Access denied for user 'dbuser'@'%' to database 'dev_db'
Typos, such fun.
Anyway, easier to fix than it might otherwise appear. Hopefully it is for you, too.
Hey, how did you enable such logs in the dev server ?
Logging is available out of the box with Symfony dev environments – in the
var/logs
directory. In this case I got the output fromvar/logs/dev.log
.Hope that helps
“I do enjoy a good error message.”
Thanks for encouraging experience!
It took me barely 2 hours to figure out that in my case that class in `security.yaml` didn’t exist:
security > providers > database_user >
-class: ‘Luzanky\Core\User\Entity\User’
+class: ‘Luzanky\Core\Entity\User’
If only there was a way in PHP to check if class_exists in throw propper exception in such places.
🙁
I never know whether to feel happy or sad when I lose hours to something that turns out to be a one line change.
On the one hand, it sucks that such a “trivial” thing can cost you so much time. But on the other hand at least it wasn’t something much bigger – like a bad design decision which requires a lot of fundamental change to your system.
Programming is just hard. At least, that’s how it feels to me. I love it. But it tests my patience pretty much daily! 😀
Glad you solved the issue anyway.