sae使用smarty模板的方法_php技巧

來源:互聯網
上載者:User

Smarty是非常流行的模板系統,它分離了業務和邏輯、執行速度快,在php網站中有廣泛的運用。

不過在部署到sina app engine(sae)上時出現了問題,因為sae作為雲端運算平台式無法進行檔案讀寫操作的,所以Smarty中輸出的快取檔案就無法實現。

錯誤資訊:“SAE_Fatal_error: Uncaught exception 'SmartyException' with message 'unable to write file ./web/templates_c/wrt4e95555280ef1' ”

SAE給出瞭解決方案就是使用Memcache。首先進入應用中的應用管理中,在服務管理中開啟Memcache一個初始化,

然後修改Smarty的設定檔:

複製代碼 代碼如下:

// For SAE 編譯檔案存放在memcache中
$smarty->compile_dir = 'saemc://smartytpl/';
$smarty->cache_dir = 'saemc://smartytpl/';
$smarty->compile_locking = false; // 防止調用touch,saemc會自動更新時間,不需要touch

上面三行是必須的。

這樣Smarty模板就可以在SAE上運行了。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.