:::
3-1 安裝Smarty樣板引擎
- Smarty的官網在:http://www.smarty.net
- Smarty 5.x 的文件在:https://smarty-php.github.io/smarty/stable/
- 用composer安裝Smarty,按 Ctrl+` 開啟終端機,並貼上:
composer require smarty/smarty - 建立四個Smarty需要的目錄,亦可按 Ctrl+` 開啟終端機,並貼上:
mkdir templates mkdir templates_c mkdir configs mkdir cache- templates:放置原始樣板的目錄(一定會用到)
- templates_c:編譯後的樣板目錄(需可寫入)
- configs:設定目錄(不見得會用到)
- cache:樣板快取目錄(需可寫入)
- 要使用Smarty佈景引擎,必須先引入自動載入檔,然後實體化一個佈景引擎,我們先建立
index.php及admin.php然後輸入:<?php require 'vendor/autoload.php'; use Smarty\Smarty; $smarty = new Smarty(); - 接著可以執行 http://localhost/php8/index.php 只要沒出現錯誤訊息就是正確的,正常的話,目前應該是一片空白。
3. 精修完整界面樣板