When rendering Symfony twig templates sometimes you might need to show one html element and hide another element depending if you have flash error/notice messages or not. For example if you have a page with registration form you might want to hide the form if it was submitted successfully and you only want to display a success message. For that you will need to check if the flash messages set by your controller are empty or not.
Continue reading “Symfony and Twig: how to check if flash messages are not empty”Category: Symfony
Symfony get HTTP_X_FORWARDED_PROTO in controller
It’s often the case that people that use Cloudflare use the SSL option of cloudflare that secures the connection from the client to Cloudflare, but not from Cloudflare to the actual hosting server. In this case people might get the impression that the user is accessing the site from https but actually the hosting server is accessed with http and Symfony’s $request->isSecure() returns false.
Continue reading “Symfony get HTTP_X_FORWARDED_PROTO in controller”