WindowsへSmartyをインストールする
Windows環境へSmartyをインストールします。
ここでは、Smarty2.6.9(2005/04/25)を対象に話を進めていきます。
Smarty から Smarty 2.6.9 を任意のフォルダにダウンロードします。
ダウンロードしたファイルを解凍します。
解凍したフォルダのlibsフォルダの中身をphpをインストールしたフォルダにコピーします。
php.iniファイルのinclude_pathを修正します。Smartyは、phpのクラスオブジェクトなので使用するときはincludeして使います。
include_path = ".;c:\php\libs"
私の場合、phpをインストールしたフォルダの下にsmartyフォルダを作成し、smartyフォルダにlibsの中身をコピーしています。
include_path = ".;c:\php\pear;c:\php\smarty"
といった配置にしています。
Apacheで設定したDocumentRootの外にcache,configs,templates,templates_cの4つのフォルダを作成します。
以上でSmartyのインストールは終了です。
phpの設定を変更していますので、Apacheを再起動します。私は、これを忘れてしばらく悩んだことがあります。
Smartyの動作確認
解凍したファイルの中のdemoフォルダ配下をフォルダも含めてApacheのDocumentRootにコピーします。(configsフォルダ,templatesフォルダ,templates_cフォルダ,index.php)
コピーしたindex.phpを修正します。
**require ‘../libs/Smarty.class.php’**を require ‘Smarty.class.php’ へ変更します。
ブラウザからindex.phpを実行します。(http://localhost/index.php)
以下のように表示されれば成功です。
Title: Welcome To Smarty!
The current date and time is 2005-01-19 19:09:26
Tooltip example: Move your mouse over the Help link to see an example of a tooltip using Smarty's popup function.
The value of global assigned variable $SCRIPT_NAME is /demo/index.php
Example of accessing server environment variable SERVER_NAME: air.tic.net
The value of {$Name} is Fred Irving Johnathan Bradley Peppergill
variable modifier example of {$Name|upper}
FRED IRVING JOHNATHAN BRADLEY PEPPERGILL
An example of a section loop:
1 * John Doe
2 * Mary Smith
3 . James Johnson
4 . Henry Case
An example of section looped key values:
phone: 1
fax: 2
cell: 3
phone: 555-4444
fax: 555-3333
cell: 760-1234
testing strip tags
This is a test