pearコマンドでPHPWebアプリケーションフレームワークSmartyをインストール
[PHP]
Smartyはpear.php.netでは配布されていませんが,
別のサイト(Pearified.com)でパッケージが配布されていて,
Channel機能を使うことでpearコマンドによりインストール可能です.
パッケージ配布先の追加
# pear channel-discover pearified.com
チャネル一覧の確認
# pear list-channels
Smartyをインストール
# pear install pearified/Smarty
ついでにJavascriptライブラリをインストール
# pear install -f pearified/Javascript_Prototype
# pear install -f pearified/Javascript_Scriptaculous
動作確認
index.php
<?php
require_once('Pearified/Smarty/Smarty.class.php');
// オブジェクトの作成
$smarty = new Smarty;
// テンプレートファイル
$smarty->template_dir = './templates/';
$smarty->assign('name', 'smarty');
$smarty->display('index.tpl');
?>
index.phpと同じ場所に templates と templates_c フォルダを作成
# mkdir templates
# mkdir templates_c
# chmod 777 templates_c
templates/index.tpl を以下の内容で作成
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTP-8">
<title>smarty test</title>
</head>
<body>
ようこそ {$name}!
</body>
</html>
index.php にアクセスし 「ようこそ smarty!」 が表示される.
2006,10,07 : 17:41 | 修正
