いけむランド

はてダからやってきました

VertrigoServ の PHP 環境に PEAR をインストールする方法

何時の間にか元の記事が消えていたため、ぐぐるキャッシュからサルベージしてきた。*1


コマンドプロンプトから VertrigoServ のインストール先 (おそらくデフォルトは C:\Program Files\VertrigoServ ) の PHP ディレクトリに移動し、PEAR/go-pear.phar を実行する。

C:\Program Files\VertrigoServ\Php>php .\PEAR\go-pear.phar

Are you installing a system-wide PEAR or a local copy?
(system|local) [system] :


そのまま enter を押下する。試してないけど、おそらく Administrator 権限がない場合に local を選べば良いと思われる。

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:\Program Files\VertrigoServ\Php
 2. Temporary directory for processing            : C:\Program Files\VertrigoServ\Php\tmp
 3. Temporary directory for downloads             : C:\Program Files\VertrigoServ\Php\tmp
 4. Binaries directory                            : C:\Program Files\VertrigoServ\Php
 5. PHP code directory ($php_dir)                 : C:\Program Files\VertrigoServ\Php\pear
 6. Documentation directory                       : C:\Program Files\VertrigoServ\Php\docs
 7. Data directory                                : C:\Program Files\VertrigoServ\Php\data
 8. User-modifiable configuration files directory : C:\Program Files\VertrigoServ\Php\cfg
 9. Public Web Files directory                    : C:\Program Files\VertrigoServ\Php\www
10. Tests directory                               : C:\Program Files\VertrigoServ\Php\tests
11. Name of configuration file                    : C:\WINDOWS\pear.ini
12. Path to CLI php.exe                           : C:\Program Files\VertrigoServ\Php

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


PEAR ディレクトリ配下に置きたいため、all と入力し、$prefix を上書きする。

Installation base ($prefix) [C:\Program Files\VertrigoServ\Php] : C:\Program Files\VertrigoServ\Php\PEAR
Temporary directory for processing [$prefix\tmp] :
Temporary directory for downloads [$prefix\tmp] :
Binaries directory [$prefix] :
PHP code directory ($php_dir) [$prefix\pear] :
Documentation directory [$prefix\docs] :
Data directory [$prefix\data] :
User-modifiable configuration files directory [$prefix\cfg] :
Public Web Files directory [$prefix\www] :
Tests directory [$prefix\tests] :
Name of configuration file [C:\WINDOWS\pear.ini] :
Path to CLI php.exe [C:\Program Files\VertrigoServ\Php] :

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:\Program Files\VertrigoServ\Php\PEAR
 2. Temporary directory for processing            : C:\Program Files\VertrigoServ\Php\PEAR\tmp
 3. Temporary directory for downloads             : C:\Program Files\VertrigoServ\Php\PEAR\tmp
 4. Binaries directory                            : C:\Program Files\VertrigoServ\Php\PEAR
 5. PHP code directory ($php_dir)                 : C:\Program Files\VertrigoServ\Php\PEAR\pear
 6. Documentation directory                       : C:\Program Files\VertrigoServ\Php\PEAR\docs
 7. Data directory                                : C:\Program Files\VertrigoServ\Php\PEAR\data
 8. User-modifiable configuration files directory : C:\Program Files\VertrigoServ\Php\PEAR\cfg
 9. Public Web Files directory                    : C:\Program Files\VertrigoServ\Php\PEAR\www
10. Tests directory                               : C:\Program Files\VertrigoServ\Php\PEAR\tests
11. Name of configuration file                    : C:\WINDOWS\pear.ini
12. Path to CLI php.exe                           : C:\Program Files\VertrigoServ\Php

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


書き換えたので今度はそのまま enter を押下すると、インストールが始まる。

Beginning install...
Configuration written to C:\WINDOWS\pear.ini...
Initialized registry...
Preparing to install...
installing phar://go-pear.phar/PEAR/go-pear-tarballs/Archive_Tar-1.3.2.tar...
installing phar://go-pear.phar/PEAR/go-pear-tarballs/Console_Getopt-1.2.3.tar...
installing phar://go-pear.phar/PEAR/go-pear-tarballs/PEAR-1.7.1.tar...
installing phar://go-pear.phar/PEAR/go-pear-tarballs/Structures_Graph-1.0.2.tar...
pear/PEAR can optionally use package "pear/XML_RPC" (version >= 1.4.0)
install ok: channel://pear.php.net/Archive_Tar-1.3.2
install ok: channel://pear.php.net/Console_Getopt-1.2.3
install ok: channel://pear.php.net/Structures_Graph-1.0.2
install ok: channel://pear.php.net/PEAR-1.7.1
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)

PEAR: To install optional features 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:\Program Files\VertrigoServ\Php\PEAR\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:\Program Files\VertrigoServ\Php\php.ini>? [Y/n] :


PEAR のディレクトリを php.ini の include_path に追加するか訊ねられるため、そのまま enter を押下する。

php.ini <C:\Program Files\VertrigoServ\Php\php.ini> include_path updated.

Current include path           : .;C:\Program Files\VertrigoServ\Smarty
Configured directory           : C:\Program Files\VertrigoServ\Php\PEAR\pear
Currently used php.ini (guess) : C:\Program Files\VertrigoServ\Php\php.ini
Press Enter to continue:

** WARNING! Old version found at C:\Program Files\VertrigoServ\Php\PEAR, please
remove it or be sure to use the new c:\program files\vertrigoserv\php\pear\pear.
bat command

The 'pear' command is now at your service at c:\program files\vertrigoserv\php\pear\pear.bat

** The 'pear' command is not currently in your PATH, so you need to
** use 'c:\program files\vertrigoserv\php\pear\pear.bat' until you have added
** 'C:\Program Files\VertrigoServ\Php\PEAR' to your PATH environment variable.

Run it without parameters to see the available actions, try 'pear list'
to see what packages are installed, or 'pear help' for help.

For more information about PEAR, see:

  http://pear.php.net/faq.php
  http://pear.php.net/manual/

Thanks for using go-pear!



* WINDOWS ENVIRONMENT VARIABLES *
For convenience, a REG file is available under C:\Program Files\VertrigoServ\Php\PEAR\PEAR_ENV.reg .
This file creates ENV variables for the current user.

Double-click this file to add it to the current user registry.


C:\Program Files\VertrigoServ\Php>


PEAR ディレクトリに移動し、pear コマンドが使えることを確認する。

C:\Program Files\VertrigoServ\Php>cd pear

C:\Program Files\VertrigoServ\Php\PEAR>pear
Commands:
build                  Build an Extension From C Source
bundle                 Unpacks a Pecl Package
channel-add            Add a Channel
channel-alias          Specify an alias to a channel name
channel-delete         Remove a Channel From the List
channel-discover       Initialize a Channel from its server
channel-info           Retrieve Information on a Channel
channel-update         Update an Existing Channel
clear-cache            Clear Web Services Cache
config-create          Create a Default configuration file
config-get             Show One Setting
config-help            Show Information About Setting
config-set             Change Setting
config-show            Show All Settings
convert                Convert a package.xml 1.0 to package.xml 2.0 format
cvsdiff                Run a "cvs diff" for all files in a package
cvstag                 Set CVS Release Tag
download               Download Package
download-all           Downloads each available package from the default channel
info                   Display information about a package
install                Install Package
list                   List Installed Packages In The Default Channel
list-all               List All Packages
list-channels          List Available Channels
list-files             List Files In Installed Package
list-upgrades          List Available Upgrades
login                  Connects and authenticates to remote server
logout                 Logs out from the remote server
makerpm                Builds an RPM spec file from a PEAR package
package                Build Package
package-dependencies   Show package dependencies
package-validate       Validate Package Consistency
pickle                 Build PECL Package
remote-info            Information About Remote Packages
remote-list            List Remote Packages
run-scripts            Run Post-Install Scripts bundled with a package
run-tests              Run Regression Tests
search                 Search remote package database
shell-test             Shell Script Test
sign                   Sign a package distribution file
uninstall              Un-install Package
update-channels        Update the Channel List
upgrade                Upgrade Package
upgrade-all            Upgrade All Packages
Usage: pear [options] command [command-options] <parameters>
Type "pear help options" to list all options.
Type "pear help shortcuts" to list all command shortcuts.
Type "pear help <command>" to get the help for the specified command.

C:\Program Files\VertrigoServ\Php\PEAR>pear list
INSTALLED PACKAGES, CHANNEL PEAR.PHP.NET:
=========================================
PACKAGE          VERSION STATE
Archive_Tar      1.3.2   stable
Console_Getopt   1.2.3   stable
PEAR             1.7.1   stable
Structures_Graph 1.0.2   stable

C:\Program Files\VertrigoServ\Php\PEAR>


Config をインストールしてみる。

C:\Program Files\VertrigoServ\Php\PEAR>pear install Config
WARNING: channel "pear.php.net" has updated its protocols, use "channel-update pear.php.net" to update
Did not download optional dependencies: pear/XML_Parser, pear/XML_Util, use --alldeps to download automatically
pear/Config can optionally use package "pear/XML_Parser"
pear/Config can optionally use package "pear/XML_Util"
downloading Config-1.10.11.tgz ...
Starting to download Config-1.10.11.tgz (27,939 bytes)
.........done: 27,939 bytes
install ok: channel://pear.php.net/Config-1.10.11

C:\Program Files\VertrigoServ\Php\PEAR>


Config を使った PHP を書いてみる。

<?php
require_once('Config.php');
$config = new Config();
echo "<pre>";
print_r($config);
echo "</pre>";
?>


ブラウザでアクセスしてみる。


Config


使用したのは VertrigoServ 2.21 です。

*1:元記事は http://d.hatena.ne.jp/hiSAtO/20080616/1213589660 にありました。