How to Fix SAE Smarty Template Engine File Write Errors
SAE Smarty errorSAE Memcache configurationSmarty template engineSAE file write errorSmarty compile directory
Published·Modified·
Recently, I used the Smarty template engine to write some small programs and wanted to test them on SAE. However, after uploading to SAE, some errors occurred. The error message was: "SAE_Fatal_error: Uncaught exception 'SmartyException' with message 'unable to write file ./...'". This is caused by the SAE platform's inability to perform file read and write operations.

1. SAE's Solution: Use Memcache
First, go to the application management in the application, and enable Memcache in the service management for initialization.
2. Modify Smarty Configuration File
// For SAE, compiled files are stored in Memcache
$smarty->compile_dir = 'saemc://smartytpl/';
$smarty->cache_dir = 'saemc://smartytpl/';
$smarty->compile_locking = false; // Prevent calling touch; saemc automatically updates the time, so touch is not needed
3. Result
Finally, the Smarty template engine can run successfully on SAE.