pear 安装

如果你需要用php写一个系统,coding from scratch不是很现实,如果你追求效率,那么使用已经写好的php类绝对是不二的选择。我今天就安装了最牛逼玩意儿,pear!

啥是pear呢?

PEAR is short for "PHP Extension and Application Repository" and is pronounced just like the fruit. The purpose of PEAR is to provide:

  • A structured library of open-source code for PHP users
  • A system for code distribution and package maintenance
  • A standard style for code written in PHP, specified here
  • The PHP Extension Community Library (PECL), see more below
  • A web site, mailing lists and download mirrors to support the PHP/PEAR community

简单翻译一下PEAR是“PHP Extension and Application Reporsitory”的简称,也就是php扩展和程序库,发音和fruit一样,PEAR的目标是:

  • 成为php用户开源代码的类库
  • 一个用于包维护和代码分发的系统
  • php代码的一种标准风格
  • php扩展社区酷
  • 支持php/pear社区的一个网站、邮件列表、下载镜像

pear不光是类库,我觉得叫类库仓库比较适合,pear和linux系统上的apt或者yum类似,维护类库以及他们的依赖性。

我的环境是windows 7,php 5.2.10(D:\phpnow\php-5.2.10-Win32目录)

下载安装好php之后,需要手动运行go-pear.bat。

D:\phpnow\php-5.2.10-Win32>go-pear.bat

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

选择系统级别安装还是本地安装,默认system,直接回车

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.  以下是默认的pear的临时、数据、配置、测试、执行目录的设置,默认回车

1. Installation base ($prefix)                   : D:\phpnow\php-5.2.10-Win32
2. Temporary directory for processing            : D:\phpnow\php-5.2.10-Win32\tmp
3. Temporary directory for downloads             : D:\phpnow\php-5.2.10-Win32\tmp
4. Binaries directory                            : D:\phpnow\php-5.2.10-Win32
5. PHP code directory ($php_dir)                 : D:\phpnow\php-5.2.10-Win32\pea
6. Documentation directory                       : D:\phpnow\php-5.2.10-Win32\doc
7. Data directory                                : D:\phpnow\php-5.2.10-Win32\dat
8. User-modifiable configuration files directory : D:\phpnow\php-5.2.10-Win32\cfg
9. Public Web Files directory                    : D:\phpnow\php-5.2.10-Win32\www
10. Tests directory                               : D:\phpnow\php-5.2.10-Win32\tes
11. Name of configuration file                    : C:\Windows\pear.ini
12. Path to CLI php.exe                           : D:\phpnow\php-5.2.10-Win32\.

1-12, 'all' or Enter to continue:
Beginning install…
Configuration written to C:\Windows\pear.ini…(pear配置文件默认写入到这里
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.2.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.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)
PEAR: To install optional features use "pear install pear/PEAR#featurename"

↑然后直接通过默认的channel:pear.php.net 开始直接下载安装pear了,这些包是默认初始化安装的,之后可以添加、删除、更新。

******************************************************************************
WARNING!  The include_path defined in the currently used php.ini does not
contain the PEAR PHP directory you just specified:
<D:\phpnow\php-5.2.10-Win32\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.

Current include path           : .;C:\php5\pear
Configured directory           : D:\phpnow\php-5.2.10-Win32\pear
Currently used php.ini (guess) :
Press Enter to continue:

接下来,需要将pear配置目录D:\phpnow\php-5.2.10-Win32\pear加入php.ini的include_path指令中。打开php.ini跳转到include_path,每个路径使用分号分隔,.表示当前目录,所以:

include_path = ".;d:\phpnow\php-5.2.10-Win32\PEAR"

然后重新启动apache,让php.ini的修改生效。

** WARNING! Old version found at D:\phpnow\php-5.2.10-Win32, please remove it or be sure to use the new d:\phpnow\php-5.2.10-win32\pear.bat command

The 'pear' command is now at your service at d:\phpnow\php-5.2.10-win32\pear.bat

然后可以通过pear.bat命令来对pear系统进行各种管理。
* WINDOWS ENVIRONMENT VARIABLES *
For convenience, a REG file is available under D:\phpnow\php-5.2.10-Win32\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目录下的PEAR_ENV.reg将PEAR的各种目录加入环境变量中。

接下来需要测试pear时候已经安装成功,新建一个php文件,写入内容:

require_once 'System.php' ;
var_dump( class_exists ( 'System' ));

如果页面返回 bool(true) 表明安装成功。

一些常用的pear命令
安装包
  pear install packagename

下载包,但不安装
  pear download packagename
  pear download-all

安装已经下载的包
  pear install filename.tgz

列出channel里面所有的包
  pear remote-list

列出已经安装的包
  pear list

列出可升级的包
  pear list-upgrades

更新包
  pear upgrade packagename
  pear upgrade-all

删除包
  pear uninstall packagename

就大概说到这里,感兴趣的可以转移到官方网站了解详情,下载一个手册也够你看1年的了,囧。

主页:http://pear.php.net/

文档:http://pear.php.net/manual/

bugs:http://pear.php.net/bugs/


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值