カテゴリ
最新の記事
以前の記事
検索
その他のジャンル
ファン
記事ランキング
ブログジャンル
画像一覧
|
Smarty 3.0 RC3 を入れて phpDocumentor で解析してみます。
・ダウンロード 公式から tar.gz をダウンロードします。 Smarty-3.0rc3.tar.gz (123.15KB) http://www.smarty.net/download.php ・展開 サーバの適当な場所に tar.gz を置いて展開すると、Smarty-3.0rc3 というディレクトリができます。実際に使用するのは libs 以下のファイルです。(しかしなぜ.DS_Store があるのかしら・・・) # tar xvfz Smarty-3.0rc3.tar.gz # cd Smarty-3.0rc3 # ls -la -rw-r--r-- 1 1001 1001 21311 7月 15 08:09 README -rw-r--r-- 1 1001 1001 4041 7月 15 08:08 SMARTY2_BC_NOTES drwxr-xr-x 6 1001 1001 4096 7月 15 08:09 demo drwxr-xr-x 4 1001 1001 4096 7月 15 08:09 libs # cd libs/ # ls -la -rw-r--r-- 1 1001 1001 6148 7月 15 08:08 .DS_Store -rw-r--r-- 1 1001 1001 27078 7月 15 08:09 Smarty.class.php -rw-r--r-- 1 1001 1001 2810 7月 15 08:08 debug.tpl drwxr-xr-x 2 1001 1001 4096 7月 15 08:09 plugins drwxr-xr-x 2 1001 1001 4096 7月 15 08:09 sysplugins ・設置 /usr/share/php/ に置きます。これは私の趣味なので、別にどこでもよいと思います。同一ホストで他のバージョンも試したい場合があるので smarty というシンボリックリンクを作って導入はとりあえず完了。 # cd /usr/share/php/ # mkdir Smarty-3.0rc3 # cd Smarty-3.0rc3/ # cp -rp /root/Smarty-3.0rc3/libs/* ./ # cd ../ # chown -R apache:apache Smarty-3.0rc3/ # ln -sfn Smarty-3.0rc3 smarty # ls -la drwxr-xr-x 4 apache apache 4096 9月 20 16:18 Smarty-2.6.26 drwxr-xr-x 4 apache apache 4096 9月 20 13:53 Smarty-3.0rc3 lrwxrwxrwx 1 root root 13 9月 20 16:18 smarty -> Smarty-3.0rc3 ・解析 (PhpDocumentor 導入) Smarty 3.0 は RC版 (Release Candidate = リリース候補) なので、公式ドキュメントはありません。試してみる上で毎回ソースを追いかけたりするのは手間なので、PhpDocumentor でドキュメントを作ってみます。 PhpDocumentor は PEAR のパッケージです。PHP のソースを解析して HTML,CHM,XML などの形式でドキュメントを出力してくれるそうです。素晴らしい。 http://pear.php.net/package/PhpDocumentor 導入は pear コマンドで実施します。XML_Beautifier というなんだかすごい名前のパッケージもいっしょにインストールされました。 # pear install PhpDocumentor Did not download optional dependencies: pear/XML_Beautifier, use --alldeps to download automatically pear/PhpDocumentor can optionally use package "pear/XML_Beautifier" (version >= 1.1) downloading PhpDocumentor-1.4.3.tgz ... Starting to download PhpDocumentor-1.4.3.tgz (2,423,486 bytes) .............................................................................................................................................................................................................................................................................................................................................................................................................................done: 2,423,486 bytes install ok: channel://pear.php.net/PhpDocumentor-1.4.3 ・解析 (PhpDocumentor 使用) 先ほど設置した /usr/share/php/smarty 以下を解析してみます。 -d 対象ディレクトリ -t ドキュメント出力先ディレクトリ -i 無視するファイル -o 出力形式 (HTML なのか PDF なのか等はこのオプションで指定) オプションの詳細はこちらを。 http://manual.phpdoc.org/HTMLSmartyConverter/PHP/phpDocumentor/tutorial_phpDocumentor.howto.pkg.html # phpdoc -d /usr/share/php/smarty -t /home/hoge001/phpdoc/Smarty-3.0rc3 -i *.tpl -o HTML:Smarty:HandS エラーがぼこぼこと出力されますが、特に気にしない。暫く経つと -t で指定したディレクトリにファイルが生成されます。 # ls -la drwxrwxr-x 15 hoge001 hoge001 4096 9月 20 12:57 Smarty -rw-rw-r-- 1 hoge001 hoge001 14512 9月 20 12:56 classtrees_Smarty.html -rw-rw-r-- 1 hoge001 hoge001 301639 9月 20 12:56 elementindex.html -rw-rw-r-- 1 hoge001 hoge001 334134 9月 20 12:56 elementindex_Smarty.html -rw-rw-r-- 1 hoge001 hoge001 26249 9月 20 12:57 errors.html -rw-rw-r-- 1 hoge001 hoge001 34511 9月 20 12:56 index.html -rw-rw-r-- 1 hoge001 hoge001 34511 9月 20 12:56 li_Smarty.html drwxrwxr-x 2 hoge001 hoge001 4096 9月 20 12:57 media -rw-rw-r-- 1 hoge001 hoge001 2675 9月 20 12:57 todolist.html index.html をブラウザから開くとドキュメントが生成されています。便利。 例えば、Smarty クラスのメソッドはこのように定義されているようです。 Smarty __construct() Class constructor, initializes basic smarty properties void __destruct() Class destructor void addPluginsDir() Adds directory of plugin files void addTemplateDir() Adds template directory(s) to existing ones object data createData() creates a data object object template createTemplate() creates a template object void disableSecurity() Disable security void display() displays a Smarty template void enableSecurity() Loads security class and enables security string fetch() fetches a rendered Smarty template string getDebugTemplate() return name of debugging template string getGlobal() Returns a single or all global variables object getRegisteredObject() return a reference to a registered object boolean isCached() test if cache i valid bool loadFilter() load a filter of specified type and name string loadPlugin() Takes unknown classes and loads plugin files for them class name format: Smarty_PluginType_PluginName plugin filename format: plugintype.pluginname.php bool setDebugTemplate() set the debug template string setExceptionHandler() Sets the exception handler for Smarty. void setTemplateDir() Set template directory boolean templateExists() Check if a template resource exists void trigger_error() trigger Smarty error void _get_filter_name() Return internal filter name void __call() Takes unknown class methods and lazy loads sysplugin files for them class name format: Smarty_Method_MethodName plugin filename format: method.methodname.php void __get() lazy loads (valid) property objects assign() が無い。およよ。 と、思ったら Smarty クラスは Smarty_Internal_Data クラスとやらの拡張クラスで assign() はそちらに定義されている模様です。 #
by hoge001
| 2010-09-20 17:36
| PHP
そろそろ環境作成も飽きてきちゃいました。コードが書きたい。
ソースを毎回サーバにアップするのは面倒なので samba を導入します。 ・導入 yum コマンドで入れます。 # yum --enablerepo=remi install samba3x Installed: samba3x.i386 0:3.3.8-0.52.el5_5.2 Dependency Installed: libtalloc.i386 0:2.0.1-7.el5 libtdb.i386 0:1.2.1-4.el5 samba3x-common.i386 0:3.3.8-0.52.el5_5.2 samba3x-winbind.i386 0:3.3.8-0.52.el5_5.2 ・設定 /etc/samba/smb.conf を編集します。今回はこんなかんじにしました。/var/www 以下をどーんと開けます。 # more /etc/samba/smb.conf [global] workgroup = MYGROUP server string = vm-test1 hosts allow = 127. 192.168.0. log file = /var/log/samba/log.%m max log size = 50 security = user passdb backend = tdbsam printing = bsd load printers = no [www] comment = www path = /var/www browsable = yes writable = yes samba を起動したときに /var/log/messages や /var/log/samba/log.smbd に下記のようなメッセージが出力される場合、printing = bsd と書いてあげるとよいようです。 こちらのサイトを参考にさせて頂きました。 http://roserogue.blogspot.com/2008/08/unable-to-connect-to-cups-server.html Sep 19 18:38:19 localhost smbd[2120]: [2010/09/19 18:38:19, 0] printing/print_cups.c:cups_connect(103) Sep 19 18:38:19 localhost smbd[2120]: Unable to connect to CUPS server localhost:631 - 接続を拒否されました Sep 19 18:38:19 localhost smbd[2121]: [2010/09/19 18:38:19, 0] printing/print_cups.c:cups_connect(103) Sep 19 18:38:19 localhost smbd[2121]: Unable to connect to CUPS server localhost:631 - 接続を拒否されました ・ユーザ作成 今までは smbpasswd でユーザを作っていましたが、@IT でこんな記事を見つけたので pdbedit コマンドを使ってみます。 # pdbedit -a -u hoge001 Cannot locate Unix account for hoge001 あら。エラーが。Linux のユーザ登録が事前に要るようです。 # useradd hoge001 # passwd hoge001 Changing password for user hoge001. New UNIX password: Retype new UNIX password: passwd: all authentication tokens updated successfully. # pdbedit -a -u hoge001 new password: retype new password: Unix username: hoge001 NT username: Account Flags: [U ] User SID: S-1-5-21-1738487938-1231891777-22550676-1000 Primary Group SID: S-1-5-21-1738487938-1231891777-22550676-513 Full Name: Home Directory: \\vm-test1\hoge001 HomeDir Drive: Logon Script: Profile Path: \\vm-test1\hoge001\profile Domain: VM-TEST1 Account desc: Workstations: Munged dial: Logon time: 0 Logoff time: never Kickoff time: never Password last set: 月, 20 9月 2010 09:51:11 JST Password can change: 月, 20 9月 2010 09:51:11 JST Password must change: never Last bad password : 0 Bad password count : 0 Logon hours : FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF ・samba 起動 #service smb start などで起動します。その後 chkconfig コマンドで自動起動にしておきます。 # service smb start
SMB サービスを起動中: [ OK ] # chkconfig smb on # chkconfig --list smb smb 0:off 1:off 2:on 3:on 4:on 5:on 6:off #
by hoge001
| 2010-09-20 11:17
| CentOS
Apache 2.2.16 でプロセスの使用メモリを減らしてみます。パーートツーー。
不要なPHP拡張モジュールのロードを止めます。 結果、 VSZ 仮想メモリ 18.40(MB) ⇒ 15.67(MB) ▲2.73(MB) RSS 物理メモリ 2.76(MB) ⇒ 2.60(MB) ▲0.16(MB) と、なりました。 Apache の不要モジュールロードを止める前から比べると、 VSZ 仮想メモリ 19.79(MB) ⇒ 15.67(MB) ▲4.12(MB) RSS 物理メモリ 3.20(MB) ⇒ 2.60(MB) ▲0.60(MB) です。それではいってみよう。 ・メモリ使用量を確認 ps コマンドで確認します。 # ps aux USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 1828 0.6 2.1 18844 5492 ? Ss 22:00 0:00 /usr/sbin/httpd apache 1829 0.0 1.1 18844 2828 ? S 22:00 0:00 /usr/sbin/httpd ... ・PHP拡張モジュールの確認 # pwd /usr/lib/php/modules # ls -la -rwxr-xr-x 1 root root 61476 7月 22 23:49 curl.so -rwxr-xr-x 1 root root 106196 8月 8 18:17 eaccelerator.so -rwxr-xr-x 1 root root 1842560 7月 22 23:49 fileinfo.so -rwxr-xr-x 1 root root 31928 7月 22 23:49 json.so -rwxr-xr-x 1 root root 257028 7月 22 23:49 phar.so -rwxr-xr-x 1 root root 13036 3月 31 15:43 phpcups.so -rwxr-xr-x 1 root root 76388 7月 22 23:49 zip.so ・PHP拡張モジュールのロードを止める 自分で入れた eaccelerator.so 以外は使う気がしないので /etc/php.d の下にある設定ファイルのロード部分をコメントアウトします。 例えば curl.so の場合 curl.ini をこんなかんじに。 # more curl.ini ; Enable curl extension module ; extension=curl.so ・Apache 再起動 # service httpd restart などで再起動します。 ・メモリ使用量を確認 おお。減りました。 # ps aux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 2142 0.6 1.9 16048 4876 ? Ss 22:23 0:00 /usr/sbin/httpd apache 2143 0.0 1.0 16048 2668 ? S 22:23 0:00 /usr/sbin/httpd ... #
by hoge001
| 2010-09-17 23:18
| Apache
Apache 2.2.16 でプロセスの使用メモリを減らしてみます。
不要なモジュールのロードを止めます。 結果から先に書くと、 VSZ 仮想メモリ 19.79(MB) ⇒ 18.40(MB) ▲1.39(MB) RSS 物理メモリ 3.20(MB) ⇒ 2.76(MB) ▲0.44(MB) と、なりました。 劇的にダイエット成功!というわけではないですが、多少は効果があるようです。 ・メモリ使用量を確認 ps コマンドで確認します。 USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1682 0.1 2.4 20784 6352 ? Ss 21:17 0:00 /usr/sbin/httpd apache 1685 0.0 1.2 20784 3280 ? S 21:17 0:00 /usr/sbin/httpd ... More... #
by hoge001
| 2010-09-16 23:22
| Apache
CentOS5.5, PHP 5.3.3 に ZendOptimizer 3.3.9 を入れてみて動かなかったとほほメモです。
ZendOptimizer http://www.zend.co.jp/ ・ダウンロード 公式から落とします。会員登録 (MyZend) が必要です。 ZendOptimizer-3.3.9-linux-glibc23-i386.tar.gz ・解凍 # tar xvfz ZendOptimizer-3.3.9-linux-glibc23-i386.tar.gz 今までのバージョンと違って、解凍しても install スクリプトがありません。 README を読んだところ、モジュールを適当な場所に置いて php.ini にパスを書きなさいとのこと。 More... #
by hoge001
| 2010-09-13 21:44
| PHP
|
ファン申請 |
||