## PEAR 소개
PEAR 는 Malin Bakken의 헌신적인 노력으로 1999-11-21에 태어날수 있었다.
PEAR 는 "PHP Extension and Application Repository"의 약자이며
PHP가 하는일을 더욱 편리하게 그리고 PHP가 하지 못하는 일을 하는 도구입니다.
PHP 코드의 구조화된 라이브러리 라고 표현 하는데 pear 홈페이지에서 얘기하는 내용을 설명하면
PEAR코드는, 「패키지」로 나뉜다. 각 패키지는 각기 개발 팀, 버젼 번호, 개발 사이클, 문서, 다른 패키지와의 의존성을 가지는 별개의 프로젝트이다. 패키지는, 설명서와 함께 gzip 압축된 tar 포멧으로 배포되고 PEAR 인스톨러(installer)로 로컬 시스템에 설치할수 있다.
PEAR 패키지에는 소스코드와 바이너리 패키지가 있다. 바이너리 배키지(경우에 따라 소스코드 포함)는 각 플렛폼에 의존적이다. 소스 패키지는 C코드로 작성된 소스 패키지를 포함하고 있을수 있으므로 설치하기 위해서는 C컴파일러가 필요하다.
PEAR는 「노드」라 불리는 1개의 패키지 트리를 정의 한다. 각 노드는 간략한 주제로 구성되어 있으며 각 파트는 언더 스코어로 구분한다. 예를들어 패키지 디렉토리 이름은 "MP3_Id", "Archive_Tar", "HTTP_Post"이다.
패키지는 명시적으로 다른 패키지와의 의존성을 포함하고 있을 가능성이 있다. 그러나 패키지와 그 패키지 트리의 「부모」의 사이와 같이 자동적인 의존성은 존재하지 않는다. (예를 들어 기본적으로 "HTTP_Post"는 "HTTP"에 독립적이다.)
패키지 트리에 있는 최상위의 소수 「sub-repositories」라고 불리는 노드의 특별한 함수는 특별한 기능을 가지고 있다. 현재 PECL, Gtk, App등이 있다. 이 노드들에 관해서는 다른 규칙이 적용된다. 자세히 알고 싶다면 아래의 sub-repositories관한 설명을 참조하라.
PHP 코딩 스타일 가이드인 PEAR 표준 코딩 및 그 규약 (PCS)은 PHP 및 PEAR어플리케이션의 공동 개발을 수월하게 한다. 또한 코드 품질 및 이식성을 높여 PEAR에 공헌하는 사람이 통일된 외관을 가지는 API를 제공할수 있게 한다. 특히, PFC 안의 패키지에 대해서는 이 표준 규약을 엄격하게 적용한다. PFC 이외의 패키지에 대해서는 보다 유연하게 적용한다.
홈페이지 :: http://pear.php.net/
====================================================================================================
## PEAR 설치
기본적으로 PEAR 은 설치되어 있지 않습니다..
하지만 간단한 설치 방법으로 PEAR 를 설치하실 수 있습니다.
: Linux 시스템에서의 설치
소스 컴파일을 해서 설치 하셨다면 기본적으로 포함되어 설치가 됩니다..
만약 컴파일 옵션에 --without-pear 를 추가 하셨다면 PEAR 는 설치가 되어 있지 않을 것 입니다.
설치가 되어 있지 않을때는 lync 를 이용하여 손 쉽게 설치하실 수 있습니다.
[root@ns /]# lynx -source http://go-pear.org/ | 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.
Go-pear also lets you download and install the PEAR packages bundled
with PHP: DB, Net_Socket, Net_SMTP, Mail, XML_Parser, phpUnit.
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::
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 : /data/PHP_Tools/PHP4
2. Binaries directory : $prefix/bin
3. PHP code directory ($php_dir) : $prefix/lib/php
4. Documentation base directory : $php_dir/docs
5. Data base directory : $php_dir/data
6. Tests base directory : $php_dir/tests
1-6, 'all' or Enter to continue:
The following PEAR packages are bundled with PHP: DB, Net_Socket, Net_SMTP,
Mail, XML_Parser, phpUnit.
Would you like to install these as well? [Y/n] :
Loading zlib: ok
Downloading package: PEAR.............ok
Downloading package: Archive_Tar......ok
Downloading package: Console_Getopt....ok
Downloading package: XML_RPC..........ok
Bootstrapping: PEAR...................(remote) ok
Bootstrapping: Archive_Tar............(remote) ok
Bootstrapping: Console_Getopt.........(remote) ok
Downloading package: DB...............ok
Downloading package: Net_Socket.......ok
Downloading package: Net_SMTP.........ok
Downloading package: Mail.............ok
Downloading package: XML_Parser.......ok
Downloading package: phpUnit..........ok
Extracting installer..................ok
sh: /usr/bin/cpp: No such file or directory
install ok: PEAR 1.3b3
install ok: Archive_Tar 1.1
install ok: Console_Getopt 1.0
install ok: XML_RPC 1.0.4
install ok: DB 1.5.0RC2
install ok: Net_Socket 1.0.1
install ok: Net_SMTP 1.2.3
install ok: Mail 1.1.2
install ok: XML_Parser 1.0.1
warning : the following errors were found:
invalid package version
install ok: PHPUnit 1.0.0-alpha2
** WARNING! Backed up old pear to /usr/local/bin/pear_old
The 'pear' command is now at your service at /data/PHP_Tools/PHP4/bin/pear
** The 'pear' command is not currently in your PATH, so you need to
** use '/data/PHP_Tools/PHP4/bin/pear' until you have added
** '/data/PHP_Tools/PHP4/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://cvs.php.net/co.php/pearweb/doc/pear_package_manager.txt?p=1
http://pear.php.net/manual/
Thanks for using go-pear!
설치 완료가 되면 PHP 가 설치된 디렉토리의 bin 디렉토리로 이동해서
[root@ns bin]# ./pear list
Installed packages:
===================
Package Version State
Archive_Tar 1.1 stable
Console_Getopt 1.0 stable
DB 1.5.0RC2 stable
HTTP 1.2.1 stable
Mail 1.1.2 stable
Net_SMTP 1.2.3 stable
Net_Socket 1.0.1 stable
PEAR 1.3b3 beta
PHPUnit 1.0.0-alpha2 alpha
XML_Parser 1.0.1 stable
XML_RPC 1.0.4 stable
확인해 보시면 설치한 패키지를 확인하실 수 있습니다.
를 확인하셔서
include_path 의 정보에 /data/PHP_Tools/PHP4/lib/php
이렇게 PEAR 가 설치된 디렉토리 /data/PHP_Tools/PHP4/lib/php 가 포함되어 있나
확인해 주시기 바랍니다.
: Windows 시스템에서의 설치
Windows 시스템에서의 설치 방법은 매우 간단 합니다.
PHP 가 설치된 디렉토리에서 go-pear.bat 파일을 실행 시킴으로서 설치를 하실 수있습니다.
만약 APM_Setup 을 사용중이시라면
C:\APM_Setup\Server\PHP4
디렉토리에서 go-pear.bat 파일을 더블클릭하여 실행 시킵니다.
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.
Go-pear also lets you download and install the PEAR packages bundled
with PHP: DB, Net_Socket, Net_SMTP, Mail, XML_Parser, phpUnit.
If you wish to abort, press Control-C now, or press Enter to continue: [Enter]
HTTP proxy (http://user:password@proxy.myhost.com:port), or Enter for none:: [Enter]
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 : C:\APM_Setup\Server\PHP4
2. Binaries directory : $prefix
3. PHP code directory ($php_dir) : $prefix\pear
4. Documentation base directory : $php_dir\docs
5. Data base directory : $php_dir\data
6. Tests base directory : $php_dir\tests
7. php.exe path : C:\APM_Setup\Server\PHP4\cli\php.exe
1-7, 'all' or Enter to continue: [Enter]
The following PEAR packages are bundled with PHP: DB, Net_Socket, Net_SMTP,
Mail, XML_Parser, phpUnit.
Would you like to install these as well? [Y/n] : [Enter]
Loading zlib: ok
Using local package: PEAR.............ok
Using local package: Archive_Tar......ok
Using local package: Console_Getopt....ok
Using local package: XML_RPC..........ok
Bootstrapping: PEAR...................(local) ok
Bootstrapping: Archive_Tar............(local) ok
Bootstrapping: Console_Getopt.........(local) ok
Using local package: DB...............ok
Using local package: Net_Socket.......ok
Using local package: Net_SMTP.........ok
Using local package: Mail.............ok
Using local package: XML_Parser.......ok
Downloading package: phpUnit..........ok
Extracting installer..................ok
install ok: PEAR 1.2.1
install ok: Archive_Tar 1.1
install ok: Console_Getopt 1.0
install ok: XML_RPC 1.0.4
install ok: DB 1.5.0RC1
install ok: Net_Socket 1.0.1
install ok: Net_SMTP 1.2.3
install ok: Mail 1.1.1
install ok: XML_Parser 1.0.1
install ok: PHPUnit 1.0.0-alpha2
******************************************************************************
WARNING! The include_path defined in the currently used php.ini does not
contain the PEAR PHP directory you just specified:
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 ? [Y/n] : [Enter]
php.ini include_path updated.
Current include path : .;c:\php4\pear
Configured directory : C:\APM_Setup\Server\PHP4\pear
Currently used php.ini (guess) : c:\windows\php.ini
Press Enter to continue:
The 'pear' command is now at your service at C:\APM_Setup\Server\PHP4\pear.bat
** The 'pear' command is not currently in your PATH, so you need to
** use 'C:\APM_Setup\Server\PHP4\pear.bat' until you have added
** 'C:\APM_Setup\Server\PHP4' 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://cvs.php.net/co.php/pearweb/doc/pear_package_manager.txt?p=1
http://pear.php.net/manual/
Thanks for using go-pear!
* WINDOWS ENVIRONMENT VARIABLES *
For convenience, a REG file is available under C:\APM_Setup\Server\PHP4\PEAR_ENV.reg .
This file creates ENV variables for the current user.
Double-click this file to add it to the current user registry.
PHP.INI 파일에는
;***** Added by go-pear
include_path=".;C:\APM_Setup\Server\PHP4\pear"
;*****
의 내용이 추가 되고 PEAR_ENV.reg 파일이 다음과 같은 내용으로 생성 됩니다.
REGEDIT4
[HKEY_CURRENT_USER\Environment]
"PHP_PEAR_SYSCONF_DIR"="C:\\APM_Setup\\Server\\PHP4"
"PHP_PEAR_INSTALL_DIR"="C:\\APM_Setup\\Server\\PHP4\\pear"
"PHP_PEAR_DOC_DIR"="C:\\APM_Setup\\Server\\PHP4\\pear\\docs"
"PHP_PEAR_BIN_DIR"="C:\\APM_Setup\\Server\\PHP4"
"PHP_PEAR_DATA_DIR"="C:\\APM_Setup\\Server\\PHP4\\pear\\data"
"PHP_PEAR_PHP_BIN"="C:\\APM_Setup\\Server\\PHP4\\cli\\php.exe"
"PHP_PEAR_TEST_DIR"="C:\\APM_Setup\\Server\\PHP4\\pear\\tests"
이제 PEAR_ENV.reg 를 더블클릭하여 레지스트리를 업데이트 합니다.
이제 PEAR 설치가 완료되었습니다.
아파치 서버를 다시 실행 해주시면 PEAR 가 적용 됩니다.