Method of using smarty template for sae

Source: Internet
Author: User
This article mainly introduces how to use the smarty template in sae. For more information, see Smarty, a very popular template system. it separates the business from the logic and performs fast, php websites are widely used.

However, a problem occurs when deploying it to sina app engine (sae). because sae cannot perform file read/write operations as a cloud computing platform, the cached 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 provided by SAE is to use Memcache. First, go to application management in the application, and enable Memcache initialization in service management,

Then modify the configuration file of Smarty:

The code is as follows:


// For SAE compiled files are stored in memcache
$ Smarty-> compile_dir = 'saemc: // smartytpl /';
$ Smarty-> cache_dir = 'saemc: // smartytpl /';
$ Smarty-> compile_locking = false; // to prevent touch calls, saemc automatically updates the time without touch

The preceding three rows are required.

In this way, the Smarty template can be run on SAE.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.