Chapter 8 PEAR セットアップ 

PEAR(PHP Extension and Application Repositoryの略で読み方は果物の梨と同じように「ペア」と発音します)とは オープンソースにて提供されているPHP開発環境用の構造化された拡張ライブラリです。

1. PEARパッケージマネージャーのインストール。

Windows版PHPでPEARを利用するにはまずパッケージマネージャーをインストールする必要があります。
インストール後にパッケージマネージャーの機能を使用して必要なライブラリーをインストールします。

1-1
, PEARパッケージマネージャーのインストールします。
 
  DOSプロンプトを起動して、PHPのインストールフォルダに移動します。
  
Microsoft Windows XP [Version 5.1.2600]
  (C) Copyright 1985-2001 Microsoft Corp.

  G:\Documents and Settings\*****>cd c:\php5

  go-pearコマンドを入力し実行する。
  c:\php5>go-pear
  Are you installing a system-wide PEAR or a local copy?
  (system|local) [system] :

  localと入力しEnterキーを押します。
  (system|local) [system] : local
  Please confirm local copy by typing 'yes' :

  yesと入力しEnterキーを押します。
  Please confirm local copy by typing 'yes' : yes

  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 base ($prefix)   : C:\php5
   2. Binaries directory            : C:\php5
   3. PHP code directory ($php_dir) : C:\php5\pear
   4. Documentation directory       : C:\php5\pear\docs
   5. Data directory                : C:\php5\pear\data
   6. Tests directory               : C:\php5\pear\tests
   7. Name of configuration file    : C:\php5\pear.ini
   8. Path to CLI php.exe           : C:\php5\.

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

  Enterキーを押します。
  Beginning install...
  Configuration written to C:\php5\pear.ini...
  Initialized registry...
  Preparing to install...
  installing phar://go-pear.phar/PEAR/go-pear-tarballs/Archive_Tar-1.3.1.tar...
  installing phar://go-pear.phar/PEAR/go-pear-tarballs/Console_Getopt-1.2.tar...
  installing phar://go-pear.phar/PEAR/go-pear-tarballs/PEAR-1.4.9.tar...
  WARNING: channel "pear.php.net" has updated its protocols, use "channel-update pear.php.net" to update
  pear/PEAR can optionally use package "pear/XML_RPC" (version >= 1.4.0)
  install ok: channel://pear.php.net/Archive_Tar-1.3.1
  install ok: channel://pear.php.net/Console_Getopt-1.2
  install ok: channel://pear.php.net/PEAR-1.4.9
  PEAR: Optional feature webinstaller available (PEAR's web-based installer)
  PEAR: Optional feature gtkinstaller available (PEAR's PHP-GTK-based installer)
  PEAR: Optional feature gtk2installer available (PEAR's PHP-GTK2-based installer)

  To install use "pear install pear/PEAR#featurename"

  ******************************************************************************
     WARNING!  The include_path defined in the currently used php.ini does not
     contain the PEAR PHP directory you just specified:
      <C:\php5\pear>
      If the specified directory is also not in the include_path used by
      your scripts, you will have problems getting any PEAR packages working.

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

      yと入力しEnterキーを押します。
      Would you like to alter php.ini <C:\php5\php.ini>? [Y/n] : y

      php.ini <D:\php\php.ini> include_path updated.

      Current include path           : .;C:\php5\includes;D:\php\PEAR\;C:\php5\smarty\libs\
      Configured directory           : C:\php5\pear
      Currently used php.ini (guess) : C:\php5\php.ini
      Press Enter to continue:

** WARNING! Old version found at C:\php5\, please remove it or be sure to use the
new C:\php5\\pear.bat command

The 'pear' command is now at your service at C:\php5\\pear.bat
続行するには何かキーを押してください . . .

  キーを押します

C:\php5\>

1-2, インストール済のPEARライブラリー確認します。

  pear listと入力、実行するとインストール済のライブラリーが一覧で表示出来ます。
  C:\php5>pear list
  INSTALLED PACKAGES, CHANNEL PEAR.PHP.NET:
   =========================================
  PACKAGE        VERSION STATE
  Archive_Tar    1.3.1   stable
  Console_Getopt 1.2     stable
  PEAR           1.4.11   stable


  ライブラリー名とバージョンとSTATEが一覧で表示されます。
  STATEはstable:安定版、beta:ベータ版、alpha:アルファ版、devel:開発版等があります。

1-3, アップグレード可能なパッケージ確認します。

C:\php5>\PEAR>pear list-upgrades
WARNING: channel "pear.php.net" has updated its protocols, use "channel-update p
ear.php.net" to update
PEAR.PHP.NET AVAILABLE UPGRADES (STABLE):
=========================================
CHANNEL      PACKAGE LOCAL          REMOTE          SIZE
pear.php.net Archive_Tar    1.3.1 (stable)  1.3.2 (stable) 16.8kB
pear.php.net Console_Getopt 1.2 (stable)    1.2.2 (stable) 4.2kB
pear.php.net PEAR           1.4.11 (stable) 1.5.1 (stable) 284kB


C:\php5

channelを設定します。


C:\php>pear channel-update pear.php.net
Retrieving channel.xml from remote server

Update of Channel "pear.php.net" succeeded

1-4, アップグレード可能なパッケージをアップグレードします。

C:\php5>pear upgrade-all
Will upgrade archive_tar
Will upgrade console_getopt
Will upgrade pear
Did not download optional dependencies: pear/XML_RPC, use --alldeps to download
automatically
pear/PEAR can optionally use package "pear/XML_RPC" (version >= 1.4.0)
downloading Archive_Tar-1.3.2.tgz ...
Starting to download Archive_Tar-1.3.2.tgz (17,150 bytes)
......done: 17,150 bytes
downloading Console_Getopt-1.2.2.tgz ...
Starting to download Console_Getopt-1.2.2.tgz (4,252 bytes)
...done: 4,252 bytes
downloading PEAR-1.5.2.tgz ...
Starting to download PEAR-1.5.2.tgz (291,323 bytes)
................................done: 291,323 bytes
downloading Structures_Graph-1.0.2.tgz ...
Starting to download Structures_Graph-1.0.2.tgz (30,947 bytes)
...done: 30,947 bytes
upgrade-all ok: channel://pear.php.net/Structures_Graph-1.0.2
upgrade-all ok: channel://pear.php.net/PEAR-1.5.2
PEAR: Optional feature webinstaller available (PEAR's web-based installer)
PEAR: Optional feature gtkinstaller available (PEAR's PHP-GTK-based installer)
PEAR: Optional feature gtk2installer available (PEAR's PHP-GTK2-based installer)

upgrade-all ok: channel://pear.php.net/Console_Getopt-1.2.2
upgrade-all ok: channel://pear.php.net/Archive_Tar-1.3.2
To install use "pear install pear/PEAR#featurename"
'PHP_PEAR_INSTALL_DIR1' は、内部コマンドまたは外部コマンド、
操作可能なプログラムまたはバッチ ファイルとして認識されていません。

C:\php5>

2. PEARパッケージのインストール確認。

2-1, pear_infoパッケージをインストールします。

C:\php5>pear install pear_info
WARNING: channel "pear.php.net" has updated its protocols, use "channel-update p
ear.php.net" to update
downloading PEAR_Info-1.6.1.tgz ...
Starting to download PEAR_Info-1.6.1.tgz (6,717 bytes)
.....done: 6,717 bytes
install ok: channel://pear.php.net/PEAR_Info-1.6.1

C:\php5>

C:\php5>>pear list
INSTALLED PACKAGES, CHANNEL PEAR.PHP.NET:
=========================================
PACKAGE          VERSION STATE
Archive_Tar      1.3.2   stable
Console_Getopt   1.2.2   stable
DB               1.7.11  stable
MDB2             2.4.0   stable
PEAR             1.5.2   stable
PEAR_Info        1.6.1   stable
Structures_Graph 1.0.2   stable

C:\php5>

3. PHPでのPEAR確認。

  以下のPHPファイルを作成し実行するとphpinfo()を実行したようにPEARのインフォメーションが表示されます。

<html>
<head>
<title>PEAR info</title>
</head>
<body>

<?php
 require_once("PEAR/Info.php");
 
 $info = new PEAR_Info();
 $info->show();
?>

</body>
</html>

 

戻る