Home  >  Article  >  Backend Development  >  PHP性能优化准备篇图解PEAR安装_php实例

PHP性能优化准备篇图解PEAR安装_php实例

WBOY
WBOYOriginal
2016-05-17 09:14:071365browse

什么是PEAR

PEAR是PHP扩展与应用库(the PHP Extension and Application Repository)的缩写。它是一个PHP扩展及应用的一个代码仓库,简单地说,PEAR就是PHP的CPAN。

为什么要安装PEAR

PEAR提供了丰富的PHP扩展工具类,简单易用,可用于各个项目之中。Benchmark是PEAR的一个扩展包,提供Timer、Iterate和Profiler三个工具类,可用于性能优化过程中的断点调试获取代码的执行时间。

如何安装PEAR

打开源码安装的PHP根目录,如C:\Program Files\php5\php-5.2.6\,双击go-pear.bat文件,图解安装过程如下

php-performance-install-pear-01


php-performance-install-pear-02


php-performance-install-pear-03


php-performance-install-pear-04


php-performance-install-pear-05


php-performance-install-pear-06


php-performance-install-pear-07


这样,PEAR就安装成功,安装过程基本上只需要按Enter键即可,非常简单。

如何安装Benchmark类

访问:http://pear.php.net/ 搜索 benchmark

(1)DOS命令安装Benchmark工具类
输入如下命令
>pear install Benchmark-1.2.7

php-performance-install-pear-08


如:C:\Program Files\php5\php-5.2.6>pear install Benchmark-1.2.7
安装成功后直接访问PEAR目录,如C:\Program Files\php5\php-5.2.6\PEAR

(2)直接下载Benchmark工具类文件

下载地址:http://pear.php.net/package/Benchmark/download
Benchmark:http://download.pear.php.net/package/Benchmark-1.2.7.tgz

直接下载解压存在PEAR目录下,如C:\Program Files\php5\php-5.2.6\PEAR

这里只讨论PEAR安装,并以Benchmark工具包为例讨论如何使用PEAR下载和安装工具类包。下一期将讨论如何使用Benchmark工具类断点调试获取代码的执行时间和函数执行的平均时间。

其它说明

CPAN是什么?
CPAN是一个巨大的PERL的扩展模块仓库,编写的应用模块可以放在CPAN下面的适当的分类目录下面,其他的人可以很方便地复用,当然,你编写应用模块时候也需要遵守其中的准则

参考资料

PEAR http://pear.php.net/
PEAR简介:用PEAR来写你的下一个php程序
 

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn