【PHP】PEAR installation
安装PEAR 官方 http://pear.php.net/manual/en/installation.cli.php There are two methods of installing PEAR A. - PEAR bundled in PHP B. - go-pear Method A 添加C:/php 到环境变量 to your PATH environment variable php.ini文件中include PEAR PHP的目录:打开windows/php.ini文件,然后查找到如下的地方: ; UNIX: "/path1:/path2" ;include_path = ".:/php/includes" ; Windows: "path1;path2" ;include_path = ".;c:phpincludes"修改成php所在目录include_path = ".;C:/php/pear". 在php5.2.5环境中,c:/php下有go-pear.bat(ms从4.04开始随PHP核心发布,除非安装时使用 ./configure option --without-pear),直接运行, 出现选择Are you installing a system-wide PEAR or a local copy? (system|local) [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. 1. Installation base ($prefix) : C:/php 2. Temporary directory for processing : C:/php/tmp 3. Temporary directory for downloads : C:/php/tmp 4. Binaries directory : C:/php 5. PHP code directory ($php_dir) : C:/php/pear 6. Documentation directory : C:/php/pear/docs 7. Data directory : C:/php/pear/data 8. Tests directory : C:/php/pear/tests 9. Name of configuration file : C:/WINDOWS/pear.ini 10. Path to CLI php.exe : C:/php/. 1-10, 'all' or Enter to continue:回车 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.6.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.6.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" WINDOWS ENVIRONMENT VARIABLES * For convenience, a REG file is available under C:/php/PEAR_ENV.reg 双击导入注册表,添加环境变量. 测试是否安装成功 C:/Documents and Settings/XXX>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.6.1 stable Structures_Graph 1.0.2 stable 至此PEAR也就安装成功,在php目录下新生成pear.bat,peardev.bat,pecl.bat,PEAR_ENV.reg,PEAR(除go-pear.phar)和tmp文件夹. Method B 如果PHP目录下没有PERL,则去http://go-pear.prg/(PEAR Package Manager)下载脚本并执行. 由于那个网站我没有链接上去过,所以没有试到是否好用. 传说中是可以这样的: $lynx source http://go-pear.org | php 这个脚本从http://go-pear.org获得脚本内容,并由PHP来执行。 如果你的系统上lynx无效,可以用其它的方法来直接获得go-pear: $wget O- http://go-pear.org | php 使用GNUS wget fetch o http://go-pear.org |php 使用fetch在FreeBSD GET http:/go-pear.org | php 使用Perl LWP的GET工具。 在Windows平台,可以使用PHP的URL流来获得,这个要求url_inclues在php.ini中没有被禁用。 C:/>php-cli r “include(‘http://go-pear.org’);” 还有一种就是直接用浏览器打开http://go-pear.org,把首页另存为go-pear.php然后在命令行中运行。 C:/php go-pear.php pear命令 安裝: a)自網路pear.php.net安裝某一個pear程式庫:pear install PackageName b)下載 packages 但不安裝:pear download packagename pear download-all c)安裝已下載的package: pear install dir/PackageName.tgz(从http://pear.php.net/package/下载了新的包xxx.tgz) 列表: a)目前pear網站上所有可取得pear程式庫列表:pear remote-list b)列出已安裝package:pear list c)列出可以升級的package:pear list-upgrades 更新(升級): 更新package:pear upgrade packagename pear upgrade-all 移除: 刪除已安裝的package:pear uninstall PackageName 实例 下载PEAR::HTML_Common 和 PEAR::HTML_QuickForm包,然后安装。 建个新的PHP文件,输入代码 require_once("HTMLQuickForm.php"); //建立一个表单对象 $form = new HTML_QuickForm( frmTest , post ); $form->addElement( header , header , 请登录 ); $form->addElement( text , name , 用户名: ); $form->addElement( password , password , 密码: ); $form->addElement( submit , submit , 提交 ); // 输出到浏览器 $form->display(); ?> 在浏览器中看看结果 |