发布于 2014-12-22 09:15:28 | 152 次阅读 | 评论: 0 | 来源: 网友投递

这里有新鲜出炉的精品教程,程序狗速度看过来!

PEAR PHP扩展与应用库

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


本文是是PHP性能优化系列第一期,如何在Windows环境下安装PEAR,并以Benchmark工具类为实例讲解PEAR如何安装扩展类。感兴趣的同学参考下。

什么是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 Filesphp5php-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 Filesphp5php-5.2.6>pear install Benchmark-1.2.7
安装成功后直接访问PEAR目录,如C:Program Filesphp5php-5.2.6PEAR

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

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

直接下载解压存在PEAR目录下,如C:Program Filesphp5php-5.2.6PEAR

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

其它说明

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

参考资料

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



最新网友评论  共有(0)条评论 发布评论 返回顶部

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务