pear
什么是Pear
来自百度百科:
PEAR是PHP扩展与应用库(the PHP Extension and Application Repository)的缩写。它是一个PHP扩展及应用的一个代码仓库,简单地说,PEAR之于PHP就像是CPAN(Comprehensive Perl Archive Network)之于Perl。
PEAR的基本目标是发展成为PHP扩展和库代码的知识库,而这个项目最有雄心的目标则是试图定义一种标准,这种标准将帮助开发者编写可移植、可重用的代码。
安装 Pear
在已经安装了 PHP 环境的前提下,进入 PHP 目录,如果没有 go-pear.php 文件,就到pear.php.net/go-pear.phar下载 go-pear.php 文件,该地址在浏览器打开可以看到一段 PHP 的代码,直接保存文件另存为 go-pear.php 到 PHP 根目录下面。
使用管理员方式打开命令行,输入以下命令:
1 cd c:\php
2 php go-pear.phar
#这时出现:
1 Are you installing a system-wide PEAR or a local copy?
2 (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.
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\docs
7. Data directory : C:\php\data
8. User-modifiable configuration files directory : C:\php\cfg
9. Public Web Files directory : C:\php\www
10. System manual pages directory : C:\php\man
11. Tests directory : C:\php\tests
12. Name of configuration file : C:\WINDOWS\pear.ini
13. Path to CLI php.exe : C:\php
20 1-13, 'all' or Enter to continue:
#直接回车,出现如下,表示安装成功,
The 'pear' command is now at your service at c:\php\pear.bat
在 PHP 根目录下面会看到如下几个文件:
双击 pear.bat 文件,注册 pear 到当前环境。
遇到问题
直接复制浏览器里的 go-pear.phar 代码到本地保存,报错:
manifest cannot be larger than 100 MB in phar "D:\tools\phpstudy\Extensions\php\php7.4.3nts\go-pear.phar"PHP Warning: require_once(phar://go-pear.phar/index.php): failed to open stream: manifest cannot be larger than 100 MB in phar "D:\tools\phpstudy\Extensions\php\php7.4.3nts\go-pear.phar" in D:\tools\phpstudy\Extensions\php\php7.4.3nts\go-pear.phar on line 1284
改成浏览器直接添加路径进行下载保存。
直接 enter 下一步报错:
**ERROR** Please, enter the php.exe path.
选择 13 ,输入 PHP 目录
D:\tools\phpstudy\Extensions\php\php7.4.3nts\