komagataのブログ

Kazuho@Cybozu Labs: mod_webdev

mod_webdev は、一言で言うと、条件つき mod_rewrite です。特殊なクッキーを伴ったリクエストについてのみ、ファイル名を書き換えることで、開発者が開発中のファイルをテストすることができます。

気味が良いツール。(そんな言葉あるのか知らんが) なんか何でも一から自分の頭で考える人感がしますよ。 そういう人は信頼できるなーって思いました。

p0t: XML食わず嫌い

PEAR::XML_RPCはHTTP/1.0なのでバーチャルホスト相手はだめなんですよね SerendipityではHTTP_Requestも併用したもので実装しました パッチ作ってコミットさせてもらいました http://sourceforge.net/mailarchive/forum.php?thread_id=7556980&forum_id=31275

投稿者 ELF : 2006年02月10日 23:33

な、なんだってー! (長くなるのでエントリーで返信)

XML-RPC Specification

Overview

XML-RPC is a Remote Procedure Calling protocol that works over the Internet.

An XML-RPC message is an HTTP-POST request. The body of the request is in XML. A procedure executes on the server and the value it returns is also formatted in XML.

Procedure parameters can be scalars, numbers, strings, dates, etc.; and can also be complex record and list structures.

XML-RPCの仕様には単にHTTP-POST requestとしか書いてないっぽい。ということはServerもClientも1.1対応してた方がいいけど別に必須ってわけじゃないってことかな?

PEARの方を見てみる。

[cvs] View of /pear/XML_RPC/RPC.php

    /**
     * Transmit the RPC request via HTTP 1.0 protocol
     *
     * @param object $msg       the XML_RPC_Message object
     * @param int    $timeout   how many seconds to wait for the request
     *
     * @return object  an XML_RPC_Response object.  0 is returned if any
     *                  problems happen.
     *
     * @see XML_RPC_Message, XML_RPC_Client::XML_RPC_Client(),
     *      XML_RPC_Client::setCredentials()
     */
    function send($msg, $timeout = 0)
    {
        if (!is_a($msg, 'XML_RPC_Message')) {
            $this->errstr = 'send()\'s $msg parameter must be an'
                          . ' XML_RPC_Message object.';
            $this->raiseError($this->errstr, XML_RPC_ERROR_PROGRAMMING);
            return 0;
        }
        $msg->debug = $this->debug;
        return $this-><strong>sendPayloadHTTP10</strong>($msg, $this-&gt;server, $this-&gt;port,
                                        $timeout, $this-&gt;username,
                                        $this->password);
    }

ん、sendPayloadHTTP10()・・・? (XML-RPCで送る中身のことをペイロードっていうらしい)

    /**
     * Transmit the RPC request via HTTP 1.0 protocol
     *
     * Requests should be sent using XML_RPC_Client send() rather than
     * calling this method directly.
     *
     * @param object $msg       the XML_RPC_Message object
     * @param string $server    the server to send the request to
     * @param int    $port      the server port send the request to
     * @param int    $timeout   how many seconds to wait for the request
     *                           before giving up
     * @param string $username  a user name for accessing the RPC server
     * @param string $password  a password for accessing the RPC server
     *
     * @return object  an XML_RPC_Response object.  0 is returned if any
     *                  problems happen.
     *
     * @access protected
     * @see XML_RPC_Client::send()
     */
    function sendPayloadHTTP10($msg, $server, $port, $timeout = 0,
                               $username = '', $password = '')
    {
    (略)

うわっ、ホントだよ。 おれも上鍵さんのパッチをパクろ・・・。

SourceForge.net: php-blog-devs

$req = new HTTP_Request( "http://".$service["host"].$service["path"]);
$req-&gt;setMethod(HTTP_REQUEST_METHOD_POST);
$req-&gt;addHeader( "Content-Type", "text/xml");
$req-&gt;addRawPostData( $message-&gt;payload);
$http_result = $req-&gt;sendRequest();
michael schurter >> Blog Archive >> Thank God for PHP_Compat

Thank God for PHP_Compat. Here’s how easy it is to use file_put_contents() in PHP4:

file_get_contents()が大好物なおれですが、そうなんですよ、PHP_Compatの何がThank Godなのかってfile_put_contents()がPHP4で使えることに決まってんだろ!ちったあ頭使え!コノ野郎!

fakemac:~% php -r 'require "PHP/Compat/Function/file_put_contents.php";
file_put_contents("foo.txt", "unk");'
fakemac:~% cat foo.txt
unk

オー ボーイ!

blogがらみの仕事でWeblogUpdates.Pingを飛ばす必要があったので毛嫌いしていたPEAR XML_RPCを使ってみました。

使ってみると・・・いいじゃないか!

デフォルトでインストールされるし! XML嫌いとか生のPOST厭だとかいってんじゃねーよ! > おれ APIとかすげー作ってみたくなってきた。

require_once("Net/URL.php");
require_once("XML/RPC.php");

/**
 * WeblogUpdates.Pingを飛ばす
 *
 * @param string $ping_server_url PingサーバのURL
 * @param string $blog_name blog名
 * @param string $blog_url blogのURL
 * @return boolean Ping送信に成功したらTRUE、失敗したらFALSE
 * @see Net_URL
 * @see XML_RPC_Client::send()
 */
function sendWeblogUpdatesPing($ping_server_url, $blog_name, $blog_url) {
    $url = new Net_URL($ping_server_url);
    $msg = new XML_RPC_Message('weblogUpdates.ping', array(new XML_RPC_Value($blog_name), new XML_RPC_Value($blog_url)));
    $cli = new XML_RPC_Client($url->path, $url->host, $url->port);
    $resp = $cli->send($msg);

    if (!$resp) {
        trigger_error("sendWeblogUpdatesPing(): ".$cli->errstr, E_USER_NOTICE);
        return FALSE;
    }

    if ($resp->faultCode()) {
        $msg = "sendWeblogUpdatesPing(): Failed to send ping. Fault Code: ".
            $resp->faultCode()." Fault Reson: ".$resp->faultString();
        trriger_error($msg, E_USER_NOTICE);
        return FALSE;
    }
    return TRUE;
}
p0t: 地味コード

PHP::Compatを使わぬとは! PEARへの愛が足りぬ!

投稿者 halt : 2006年02月07日 14:52

haltさんの叱咤によりPEAR愛が高まったというかPHP::Compatに俄然興味が出たので調べてみました。

PHP::Compatのcompatはcompatibility(互換性)の略で、後のバージョンで新しく出来た関数や定数をヘボイバージョンにも提供してくれる素晴らしいライブラリだそうです。 特に前述のPATH_SEPARATOR(: or ;)やDIRECTORY_SEPARATOR(/ or \)やPHP_EOL(\n or \r\n or \r)などの無いと激しく萎える存在を提供してくれるのでありがたい。関数も単体でloadできるのでシンプルで良い。 アプリに手を入れずに古いPHPで動かしたい場合にiniのauto_prepend_fileディレクティブにこれらの読み込みファイルを設定してみるっつーのも試してみる価値ありそう!

ついでに気になったPHP_CompatInfoも調べてみました。

PEAR :: Package :: PHP_CompatInfo

>> Description PHP_CompatInfo will parse a file/folder/script/array to find out the minimum version and extensions required for it to run. Features advanced debug output which shows which functions require which version and CLI output script

こっちはPHPのコードを調べてバージョンいくつ以上で動くのか調べてくれるらしい。試しにmojavi-all-classes.phpを調べてみました。

fakemac:~/src/mojavi-2.0.0% cat ~/project/php-examples/compat/compatinfo.php
#!/usr/bin/env php
&lt;?php
require_once("PHP/CompatInfo/Cli.php");
$ci = new PHP_CompatInfo_Cli();
$ci-&gt;run();
?&gt;
fakemac:~/src/mojavi-2.0.0% ~/project/php-examples/compat/compatinfo.php --file=mojavi-all-classes.php
+------------------------+---------+------------+------------------+
| File                   | Version | Extensions | Constants/Tokens |
+------------------------+---------+------------+------------------+
| mojavi-all-classes.php | 5.0.0   | session    | implements       |
|                        |         |            | interface        |
|                        |         |            | protected        |
|                        |         |            | private          |
|                        |         |            | __LINE__         |
|                        |         |            | final            |
|                        |         |            | clone            |
|                        |         |            | throw            |
|                        |         |            | catch            |
|                        |         |            | abstract         |
+------------------------+---------+------------+------------------+

5.0.0?んなこたぁないハズ。おれの理解が間違ってるのかも!

debian woodyのPHP 4.1.2でPATH_SEPARATORが無いとお嘆きの方へ。

!defined("PATH_SEPARATOR") and strtoupper(substr(PHP_OS, 0, 3) !== "WIN") ? define("PATH_SEPARATOR", ":") : define("PATH_SEPARATOR", ";");
KANOU.JP: メタ構文変数

ちなみに英語圏のメタ構文変数「foo」「bar」は有名だけど、その後も続きがあって「baz」「quux」「foobar」らしい。「quux」は読めない。

ああ、ずっとbazの先が知りたかったんだ。読めないのが難点だけど。

php4以外にもlibphp-でいくつかあるということを知りました。 気になったのがその中にあるlibphp-diogenes。

diogenesって何だと思って調べてみました。

Polytechnique.org Free Software -Diogenes-

diogenesってCMSがあってそれに使われてるライブラリだそうです。

diogene-2.png

diogene-1.png

これで作られてるサイト例、

  • x-org.polytechnique.org
  • dev.jerryweb.org
  • doc.polytechnique.org

と、いわれてもどれも知らんな・・・。 ぱっと見wysiwygエディタが目を引いた。 といってもEkitというGPLのappletを使ってるらしい。 ここはひとつJSでがんばって欲しいところ。 残念ながらソースを見る気力が無かったのでここまで!

ref: PHP関連のパッケージ

Fedora Core 5はPHPの環境が充実している – よくきたblog

今少しだけFedora Core 5 test 2を試用しているんだけどphp関連のパッケージが結構充実しています

smartyやadodbまでパッケージになってるとは。こういうとこが地味に嬉しかったりするので気になる。

Debian etchではどうなってんのか調べてみた。

colinux:~% apt-cache search ^php4
php4 - server-side, HTML-embedded scripting language (meta-package)
php4-apd - PHP code execution profiler and debugger
php4-cgi - server-side, HTML-embedded scripting language (CGI binary)
php4-clamavlib - PHP ClamAV Lib - ClamAV Interface for PHP4 Scripts
php4-cli - command-line interpreter for the php4 scripting language
php4-common - Common files for packages built from the php4 source
php4-curl - CURL module for php4
php4-dev - Files for PHP4 module development
php4-domxml - XMLv2 module for php4
php4-gd - GD module for php4
php4-gpib - libgpib php bindings
php4-idn - PHP api for the IDNA library
php4-imagick - ImageMagick module for php4
php4-imap - IMAP module for php4
php4-interbase - InterBase (FireBird) module for PHP4
php4-json - json serialiser for PHP4
php4-ldap - LDAP module for php4
php4-mapscript - module for php4-cgi to use mapserver
php4-maxdb - PHP extension to access MaxDB databases
php4-mcal - MCAL calendar module for php4
php4-mcrypt - MCrypt module for php4
php4-mhash - MHASH module for php4
php4-mysql - MySQL module for php4
php4-odbc - ODBC module for php4
php4-pear - PHP Extension and Application Repository (transitional package)
php4-pear-log - Log module for PEAR
php4-pgsql - PostgreSQL module for php4
php4-ps - An extension to create PostScript files
php4-recode - Character recoding module for php4
php4-snmp - SNMP module for php4
php4-spplus - Secured payment system of the Caisse d'Epargne (French bank)
php4-sqlite - PHP4 bindings to SQLite, a file-based SQL engine
php4-sqlrelay - SQL Relay PHP API
php4-sybase - Sybase / MS SQL Server module for php4
php4-syck - YAML parser kit -- PHP4 bindings
php4-uuid - OSSP uuid module for php4
php4-xslt - XSLT module for php4

ああ、やっぱりFedora Core 5の方が揃ってる気がする!

mixiコミュニティ [Let’s PHP]

4: xxxxxxx

投書ありがとうございます。

まだちょっとゆっくり話します。小さいxxx研究団体の日本代表部に仕事しますから日本語をあまり喋られないけど、機会を与える会社があれば進行が早いですよ。

場数を踏んでいて敏腕を振るいたいですね。相応な会社を知れば紹介して下さい!

斬新なやる気表現に心打たれた! たぶん文法は間違ってないと思うよ!