Do You PHP はてブロ

Do You PHPはてなからはてブロに移動しました

firefox2.0でLiveHTTPHeaders

f:id:shimooka:20061025094640p:image

相変わらず新しいバージョンがリリースされないLiveHTTPHeadersですが、「インストール時の対象バージョンを書き換えたらうまくいくかも」と思ってググってみると、やはり同じ事を考える人はたくさんいるようで、1.5+用の0.12の設定ファイルをちょっとだけ書き換えることで使えるようです。先日エントリしたBe Stiqを作ってらっしゃるRAKUTOさんのblogでした :-)


ブログにするほどのネタではない。
Live Http Headers プラグインが2.0に対応するバージョンが配布されていないので、手動でmaxVersionを書き換えてインストールする必要がある。

いえいえ。充分なネタですよ :-)
ということで、Linux版firefox2.0で試してみました。まずは、LiveHTTPHeadersのページからバージョン0.12をダウンロードし、以下の要領でinstall.rdfを編集して再度パッケージし直します。

$ file livehttpheaders-0.12.xpi
livehttpheaders-0.12.xpi: Zip archive data, at least v1.0 to extract
$ mkdir temp
$ unzip livehttpheaders-0.12.xpi -d temp/
Archive:  livehttpheaders-0.12.xpi
   creating: temp/chrome/
  inflating: temp/chrome/livehttpheaders.jar
   creating: temp/components/
  inflating: temp/components/nsHeaderInfo.js
   creating: temp/defaults/
  inflating: temp/defaults/LiveHTTPHeaders.ico
  inflating: temp/defaults/LiveHTTPHeaders.xpm
   creating: temp/defaults/preferences/
  inflating: temp/install.js
  inflating: temp/install.rdf
  inflating: temp/TODO.txt
$ cd temp/
$ cp -p install.rdf install.rdf.org
$ vi install.rdf
$ diff install.rdf install.rdf.org
16c16
<         <em:maxVersion>2.*</em:maxVersion>
---
>         <em:maxVersion>1.5+</em:maxVersion>
$ zip -u ../livehttpheaders-0.12.xpi install.rdf
updating: install.rdf (deflated 67%)
$ 

できたlivehttpheaders-0.12.xpiをインストールし、Firefoxを再起動すると使えるようになります。今のところ、問題なく動作しています。

PHP5.2.0のReflectionProperty


本家のphp-devネタですが、PHP5.2.0では非publicなメンバーの値がReflectionProperty#getValue()で取得できなくなっちゃってますね。。。

<?php
    class MyClass {
      protected $foo = 'bar';
    }
    
    $myobj = new MyClass();
    $c = new ReflectionClass($myobj);
    $p = $c->getProperty('foo');  // ReflectionPropertyオブジェクトが返る
    echo $p->getValue($myobj); // 「bar」が表示されるはず
?>

PHP5.1.6では「bar」が出力されますが、PHP5.2.0では

ReflectionException: Cannot access non-public member MyClass::foo ...

となります(CentOS4.4+PHP5.2.0で確認)。リフレクションをガシガシ使っている方は注意が必要です。

PHP5.2.0のgo-pear.batは壊れているっぽい


Windows XP(SP2)にPHP5.2.0をインストールし、go-pear.batを実行したところ、

Warning: Cannot use a scalar value as an array in phar://go-pear.phar/PEAR/...

が頻発してインストール失敗。調べてみると、


I think that in general a formal bug report is better, but in this case,
I happened to catch your message and have just committed a fixed
go-pear.phar. Thanks so much for reporting this, the changes to PHP 5.2
that caused this failure seem to have slipped in under the radar.

ということで、バグが紛れ込んでしまったようです。修正版がすでにcommitされているようなので、cvs.php.netからダウンロードしようとしたんですが、今度はhttpdの反応が。。。:-(
メーリングリストをもうちょっと読み進めていくと、


The fix I committed was to http://pear.php.net/go-pear.phar , which is a
copy of cvs.php.net's pearweb/public_html/go-pear.phar

とあり、早速ダウンロードしてPEARディレクトリに保存。再度go-pear.batを実行すると、今度はうまくいきました。

追記(2008/02/27 00:22)

壊れているのを確認したのは、今のところ5.2.0のみです。それ以降は修正されているはずです。インストールできない場合、次のエントリも参照してみてください。

まあ、pearコマンドが使えなくなったらどうするか - Do You PHP はてなにもあるように、http://pear.php.net/go-pear を使ってインストールしても同じなんですけどね。

ちなみに、go-pear.pharをテキストエディタで開いたときに文字化けして見えるのは、文字化けでは*ありません*。ちゃんとしたバイナリデータ(Pharマニフェスト)です。