sae USES the smarty template method

  • 2020-11-30 08:12:47
  • OfStack

Smarty is a popular template system that separates business and logic, performs quickly, and is widely used in php websites.

However, there was a problem when deploying to sina app engine (sae) because sae as a cloud platform could not read and write files, so the output cache files in Smarty could not be implemented.

Error message: "SAE_Fatal_error: Uncaught exception 'SmartyException with message' unable to write file. / web/templates_c/wrt4e95555280ef1 '"

The solution given by SAE is to use Memcache. First, enter the application management in the application. Start Memcache1 initialization in the service management.

Then modify the CONFIGURATION file for Smarty:


// For SAE  Compile files are stored in memcache In the 
$smarty->compile_dir = 'saemc://smartytpl/';
$smarty->cache_dir = 'saemc://smartytpl/';
$smarty->compile_locking = false; //  To prevent the call touch,saemc Will automatically update the time, no need touch

The top 3 lines are required.

This allows the Smarty template to run on SAE.


Related articles: