Unless I am missing something, the template syncing behavior leaves a big gap in how developers would typically want to work with templates on a production website.
Local dev environment: * Save templates as files = yes. * Edit template files in my IDE. * Check templates into source control (github repo).
Production environment: * Save templates as files = NO. * Pull down latest from github. * ??? There’s no way to tell EE (3.4.6) to sync all templates (is there?).
I found an add-on that turns things upside-down, that will actually remove templates from the database if the file goes away, but that still only works at runtime and depends on the “save as files” feature to be turned on.
Please advise - I would like to sync all in one go. Thanks.
As I understand it, the template system does a check when it loads pages to see if the template file’s save date differs from the date marked in the database, and then copies the file to the database if it does differ. To make this check every page load seems quite inefficient to me. Is that an incorrect impression of what’s going on? In the case of dynamic pages where I cannot have the entire template cached, but only parts of it, this seems especially problematic, since it would have to happen every page load, not just once before the template is cached.
You’re correct. But in 99.999999995% of cases that check should have no performance hit. I have a site that gets over a million views each month and it’s never been an issue.
Another option is to upload and then turn Save Templates as Files on and then off. I believe in 3.x when you turn it on, it syncs. Give it a shot?
Yes, if you enable saving as a files, upload/deploy all of the latest templates files, and then hit the Template Manager, your templates from the file system will sync to the database.
I’d echo Pedro though, there’s no performance reason to disable this on production, I think that’s a bit of FUD that is leftover from the days of PHP 4. You can always check if you have a measurable difference in performance after enabling (check a before and after with Debugging enabled). If you notice a difference, come back here and we can troubleshoot—it would likely mean a bigger environmental issue that if addressed would have a major impact on server resource usage.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.