Solution for SAE Error with Smarty Template Engine

Publish: 2015-01-07 | Modify: 2015-01-07

Recently, I have been using smarty templates to write some small programs. I wanted to test them on SAE, but encountered an error after uploading to SAE. The error message is: "SAE_Fatal_error: Uncaught exception 'SmartyException' with message 'unable to write file ./...' ". This is because SAE platform does not support file read and write operations.

To solve this issue, SAE provides a solution which is to use Memcache. Here are the steps:

  1. Go to the application management in SAE and enable Memcache in the service management.

  2. Modify the Smarty configuration file:

// For SAE, store compiled files in memcache
$smarty->compile_dir = 'saemc://smartytpl/';
$smarty->cache_dir = 'saemc://smartytpl/';
$smarty->compile_locking = false; // Prevent calling touch, saemc will automatically update the time, no need for touch
  1. With these changes, the Smarty template engine can successfully run on SAE.

Comments