PHPのお勉強

これまでPHPはまったく触ったことがなかったので勉強中。
今日はMacOSXPEARをインストールしてみる。PEARrubyrubygemsみたいなもので、簡単にphpのライブラリをインストールするための仕組み。

とりあえずこんなかんじでインストール。

curl http://pear.php.net/go-pear > go-pear.php
sudo php -q go-pear.php 

Welcome to go-pear!
..
HTTP proxy (http://user:password@proxy.myhost.com:port), or Enter for none:: 
...
 1. Installation prefix ($prefix) : /Users/ken
 2. Temporary files directory     : $prefix/temp
 3. Binaries directory            : $prefix/bin
 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

1-7, 'all' or Enter to continue: 1
Installation prefix ($prefix) [/Users/ken] : /usr/lib/php/PEAR

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) : /usr/lib/php/PEAR
 2. Temporary files directory     : $prefix/temp
 3. Binaries directory            : $prefix/bin
 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

1-7, '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] : 
...
******************************************************************************
WARNING!  The include_path defined in the currently used php.ini does not
contain the PEAR PHP directory you just specified:
</usr/lib/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 </private/etc/php.ini>? [Y/n] : Y

php.ini </private/etc/php.ini> include_path updated.

Current include path           : .:/usr/lib/php/Smarty
Configured directory           : /usr/lib/php/PEAR/PEAR
Currently used php.ini (guess) : /private/etc/php.ini
Press Enter to continue: 

The 'pear' command is now at your service at /usr/lib/php/PEAR/bin/pear

** The 'pear' command is not currently in your PATH, so you need to
** use '/usr/lib/php/PEAR/bin/pear' until you have added
** '/usr/lib/php/PEAR/bin' 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!

% 

/Users/kenにインストールされるのはなんか気持ち悪かったので/etc/lib/php/PEARに変更した。すると/etc/lib/php/PEAR/PEARというフォルダができてしまい、さらに気持ち悪かったが、まあよしとする。

DBライブラリをインストールしてみる。

% sudo pear install DB
Password:
WARNING: "pear/DB" is deprecated in favor of "pear/MDB2"
downloading DB-1.7.13.tgz ...
Starting to download DB-1.7.13.tgz (132,246 bytes)
.............................done: 132,246 bytes
install ok: channel://pear.php.net/DB-1.7.13