Smarty is a very popular template system. It separates business and logic, has fast execution speed, and is widely used in PHP websites.
However, there was a problem when deploying to Sina App Engine (sae). Because sae, as a cloud computing platform, cannot perform file reading and writing operations, the cache files output in Smarty cannot 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 and enable Memcache initialization in the service management,
Then modify Smarty’s 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 will automatically update the time, no touch is required
The above three lines are required.
In this way, the Smarty template can be run on SAE.
Excerpted from 〃Style ひぐ