- 2011-06-26 (日) 23:00
- PHP
この記事の所要時間: 約 4分30秒
コマンドラインからPHPマニュアルを見ることができるpmanコマンドが登場しました。

manコマンドのようにコマンドラインからPHP関数やSPLのクラスについて調べることができます。
インストール
pearコマンドでインストールします。
$ sudo pear install doc.php.net/pman
手元のMac OS X 環境では、/usr/bin/ に pman コマンドがインストールされました。
$ which pman /usr/bin/pman
使い方
pmanコマンドに調べたい関数名を指定します。例えば、array_map のマニュアルを見たいなら以下のように指定します。
$ pman array_map
ARRAY_MAP(3) 1 ARRAY_MAP(3)
array_map - Applies the callback to the elements of the given arrays
SYNOPSIS
array array_map (callback $callback, array $arr1, [array $...])
DESCRIPTION
array_map(3) returns an array containing all the elements of $arr1 after applying the $callback func-
tion to each one. The number of parameters that the $callback function accepts should match the num-
ber of arrays passed to the array_map(3)
PARAMETERS
o $callback
- Callback function to run for each element in each array.
o $arr1
- An array to run through the $callback function.
o $array
- Variable list of array arguments to run through the $callback function.
RETURN VALUES
Returns an array containing all the elements of $arr1 after applying the $callback function to each
one.
(snip)
SPLなどオブジェクトのメソッドを調べるなら、クラス名+”.”+メソッド名を指定します。下記では、Exceptionクラスのコンストラクタを指定しています。
$ pman Exception.__construct
EXCEPTION.__CONSTRUCT(3) 1 EXCEPTION.__CONSTRUCT(3)
Exception::__construct - Construct the exception
SYNOPSIS
public Exception::__construct NULL ([string $message = ""], [int $code], [Exception $previous])
DESCRIPTION
Constructs the Exception.
PARAMETERS
o $message
- The Exception message to throw.
o $code
- The Exception code.
o $previous
- The previous exception used for the exception chaining.
(snip)
pman=ビーマン?
pmanコマンドの名称は「PHP man pages」です。呼び名はやっぱり「ピーマン」ですかね。
名前が示すとおり、pmanコマンドの実装を見てみると、manコマンドをラップしているだけでした。
今のところ英語版しか無いようですが、array関係など引数の順序があいまいな時にさっと調べるには便利そうです。
- Newer: 現状のPHP環境はそのままで、PHP 5.4 を試す
- Older: 動作中のハードディスクの動きが見える2分の動画
トラックバック:0
- このエントリーのトラックバックURL
- /blog/2011/06/php_pman.html/trackback
- Listed below are links to weblogs that reference
- コマンドラインからPHPマニュアルを見るpmanコマンド from Shin x blog

