Windows版PHPにPEAR・PECLをインストールする

PEAR(PHP Extension and Application Repository)とはPHPの拡張ライブラリの1つです。

PerlでいえばCPAN(Comprehensive Perl Archive Network)、 TeXでいえばCTAN(Comprehensive TeX Archive Network)に該当します。

Linux版PHPには標準でPEARで組み込まれていますが、Windows版PHPでは通常組み込まれていないため、手動でインストールする必要があります。

公式サイト
日本語マニュアル
インストールの詳細
共有サーバでPEARの使用

[参考記事] PEARを更新する方法
[参考記事] コマンドラインからpearを実行するとエラーが出る 環境変数PHP_PEAR_PHP_BINの設定
[参考記事] Unix・Linux版PHPにPEAR・PECLをインストールする方法

パッケージマネージャのインストール

下記のURLより、PEARインストールのためのPHPのソースコードをダウンロードします。
http://pear.php.net/go-pear

これをgo-pear.phpとして保存します。

実行方法1

go-pear.phpをPHPのインストールフォルダに、PEARというフォルダを作って、そこに保存します。

また次のコードを、go-pear.batとして、PHPのインストールフォルダに保存し、実行します。

@ECHO OFF
set PHP_BIN=php.exe
%PHP_BIN% -d output_buffering=0 PEAR\go-pear.php
pause

階層

PHPのインストールフォルダ(C:\Program Files\PHP または C:\PHP)
├ PEAR
│└ go-pear.php
└ go-pear.bat

実行方法2

go-pear.phpをPHPのインストールフォルダに保存します。

コマンドプロンプトより

C:\>cd C:\Program Files\PHP
C:\Program Files\PHP>php go-pear.php

を実行します。

Welcome to go-pear!

Go-pear will install the 'pear' command and all the files needed by
it.  This command is your tool for PEAR installation and maintenance.

Use 'php go-pear.php local' to install a local copy of PEAR.

Go-pear also lets you download and install the following optional PEAR
packages: PEAR_Frontend_Web-beta, PEAR_Frontend_Gtk2, MDB2.


If you wish to abort, press Control-C now, or press Enter to continue:

HTTP proxy (http://user:password@proxy.myhost.com:port), or Enter for none::

*WARNING*
We found php.exe under c:\program files\php\php.exe, it uses an unknown SAPI. PE
AR commandline
tool has not been tested with it, if you have a CLI (or CGI) php.exe available,
we strongly recommand to use it.


Below is a suggested file layout for your new PEAR installation.  To
change individual locations, type the number in front of the
directory.  Type 'all' to change all of them or simply press Enter to
accept these locations.

 1. Installation prefix ($prefix) : C:\Program files\PHP
 2. Temporary files directory     : $prefix\temp
 3. Binaries directory            : $prefix
 4. PHP code directory ($php_dir) : $prefix\pear
 5. Documentation base directory  : $php_dir\docs
 6. Data base directory           : $php_dir\data
 7. Tests base directory          : $php_dir\tests
 8. php.exe path                  : c:\program files\php\php.exe

1-8, 'all' or Enter to continue:

The following PEAR packages are bundled with PHP: PEAR_Frontend_Web-beta,
PEAR_Frontend_Gtk2, MDB2.
Would you like to install these as well? [Y/n] : Y

Loading zlib: ok

Bootstrapping Installer...................
Bootstrapping PEAR.php............(remote) ok
Bootstrapping Archive/Tar.php............(remote) ok
Bootstrapping Console/Getopt.php............(remote) ok

………………
………

Would you like to alter php.ini <C:\Program Files\PHP\php.ini>? [Y/n] : Y

………………
………

PEARコマンド

コマンド説明
pear helppearのヘルプを表示します
pear help [command]pearコマンドのヘルプを表示します
prar listローカルにインストールされているPEARパッケージの一覧を表示します
pear remote-listリモートからインストール可能なPEARパッケージの一覧を表示します
pear search [packagename]リモートからインストール可能なパッケージを検索します
pear install [packagename]パッケージをインストールします
pear install -a [packagename]パッケージをインストールします
※依存しているパッケージも自動的にインストールします(-aオプション)

関連記事

スポンサーリンク

chiaのサービスを開始したときにfailed to start. Error: start failedで開始できない

ホームページ製作・web系アプリ系の製作案件募集中です。

上に戻る