<< 2024 年 5 月 >>
28
29
30
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
1


 トップ > 知識ベース  備忘録のようなメモ書き集です。

Smarty

ロゴ画像中に TEMPLATE ENGINE とあるように、Smarty はテンプレートエンジンの一つです。ウェブサイトでは、複数のページをコンテンツだけを入れ替えて同じレイアウトで見せることが、ユーザビリティの観点からよくあります。この場合、見せ方を規定するのがテンプレートです。Smartyは、このテンプレートとコンテンツを結合するエンジンの役割をします。

エンジンの使用手順です。まず、データソースからコンテンツを抽出加工するプログラム中に Smarty オブジェクトを宣言します。次に、そのオブジェクトを介して、コンテンツとなるデータをテンプレートに渡します。最後に、テンプレートを表示させます。Smarty は、PHP というプログラム言語で書かれているので、Smarty を使用するプログラムも PHP で書きます。記述例は次のとおりです。

require_once(SMARTY_ROOT . LIB_DIR . 'Smarty.class.php');
$smarty = new Smarty;

$smarty->assign('contents', 'この文字列がテンプレートに渡されます。テンプレートでは、{$contents}で参照されます。');

$smarty->display($template);

Smarty の本質的価値は、コンテンツの見せ方であるプレゼンテーションとコンテンツを集約するビジネスロジックを分けることで、前者をテンプレートデザイナーが、後者をプログラマーが担当するというように分業を可能にし、これにより開発/保守効率を高める点にあります。

PHP は <?php?> で囲まれた内部をプログラムコードとして解釈し実行します。囲まれていない部分は、HTMLコードとしてそのまま出力されます。ひとつのスクリプトファイルにプレゼンテーションとビジネスロジックを簡単に切り替えて書くことを意図して作られた言語です。PHP 本来の特徴を生かすことで、わざわざ Smarty を使う必要がないのではないかという批評について、WIKIPEDIA http://en.wikipedia.org/wiki/Smarty で触れられています。no smarty というサイトも、Smarty の特徴を掴むうえで参考になります。


Smarty Php Template Programming And Applications

Smarty のドキュメントは日本語でも入手できます。私が初めて Smarty に触れたのは2006年、バージョンは 2.6.11でした。当時の公式サイトには、ドキュメントの日本語訳がありませんでした。でも、高木正弘さん、森川穣さん、亀本大地さん、松田晋介さんのご努力のお陰で、現在は日本語で Smarty のドキュメントを読むことができます。*1 *2 以下は、Smarty の公式サイト http://www.smarty.net/ からの引用です。

Japanese translation available!
[4-May-2007] The Japanese documentation is here! Thanks goes to Masahiro Takagi, Joe Morikawa, Daichi Kamemoto, and Shinsuke Matsuda for their hard work.


(知識ベース)2010/07/18 20:11 コメント(1)

XAMPP

XAMPP はウェブサーバーパッケージの一つです。特徴は無料で使えること。GNU General Public License のもとに公開されています。オープンソースです。また、Microsoft Windows、Linux、Solaris、Mac OS X 等、複数のプラットフォームで動かせるものとして、提供されています。主な構成は、Apache HTTP サーバー、MySQL データベース、そしてプログラム言語 PHP または Perl で書かれたスクリプトを解釈するインタプリターから成っています。

XAMPP の読み方はザンプまたはエグザンプのようです。私はどちらかというとグザンプと、エを聞こえないように読んでいます。

XAMPP の設計者は、ウェブサイトのデザイナーやプログラマーがインターネット接続をしないで作品をテストできるようにと、開発用に XAMPP を考えたようです。そのため、多くのセキュリティ機能が初期状態でオフになっていますが、XAMPPを公開サーバーとして使用するときには、セキュリティ面での設定変更が必要になるようです。

XAMPP は公式サイトAPACHE FRIENDSから入手できます。

以下は、http://en.wikipedia.org/wiki/XAMPPからの引用です。

XAMPP (pronounced /ˈzæmp/ or /ˈɛks.æmp/) is a free and open source cross-platform web server package, consisting mainly of the Apache HTTP Server, MySQL database, and interpreters for scripts written in the PHP and Perl programming languages.

XAMPP's name is an acronym for:
・X (meaning cross-platform)
・Apache HTTP Server
・MySQL
・PHP
・Perl

The program is released under the terms of the GNU General Public License and acts as a free web server capable of serving dynamic pages. XAMPP is available for Microsoft Windows, Linux, Solaris, and Mac OS X, and is mainly used for web development projects.

Officially, XAMPP's designers intended it for use only as a development tool, to allow website designers and programmers to test their work on their own computers without any access to the Internet. To make this as easy as possible, many important security features are disabled by default. In practice, however, XAMPP is sometimes used to actually serve web pages on the World Wide Web. A special tool is provided to password-protect the most important parts of the package.


(知識ベース)2010/07/16 23:59 コメント(0)