Scott Cottam

scott@scottcottam.co.uk

Symfony 4 On Shared Hosting

15th August, 2019

Over the last month or so I’ve been working on a project using the Symfony framework as it is sort of the basis for Laravel, apart from a few moments of pulling my hair out but that is mainly getting used to the database side of the framework as it uses Doctrine, I have really grown to like Symfony over Laravel as it feels a lot less bulky.

But this post really isn’t to discuss the merits of Symfony vs Laravel, it is however to talk about the caching Symfony does for its Twig templates as well as the Doctrine database queries, the caching does over all reduce system loads when sites built with Symfony are loaded and reloaded by its users.

In the dev environment changes to Twig templates and Doctrine queries aren’t cached quite as aggressively as when a Symfony project is set to production, in development a simple refresh is all that is required to show the new changes but when it is set to production you’re told to use the command line and clear the cache using ‘php bin/console cache:pool:clear cache.global_clearer’ so it makes any last minute changes or major updates of an already deployed site a bit more of a labourious endeavour.

Anyone using shared hosting will tell you it isn’t always that easy as a lot of shared hosting packages won’t let you connect to the hosting service using SSH, you can do this in Dreamhost but it is a pain to set up, the solution I came to was to connect to your host using FTP and delete the contents of the /var/ directory and reload the page and the changes you have made will be displayed.