PHP下安装phpunit 及xdebug
?? ? ? 话说之前在公司安装了下phpunit,测试了~~可是输出代码测试覆盖率,需要有php的扩展xdebug,就去网上找了这个xdebug?(<span style="color: #000000;">www.xdebug.org</span>),下载。
?? ? ? 在公司的用的集成环境,下了一个5.2 Vc6(32bit)的,然修改名字为php_xdebug.dll ,然后按照教程说的配置php.ini文件如下:
[Xdebug]
zend_extension_ts="c:/wamp/php/ext/php_xdebug.dll"
xdebug.profiler_enable=on
xdebug.trace_output_dir="D:/PHPApp/xdebug"
xdebug.profiler_output_dir="D:/PHPApp/xdebug"
?
可是发现,xdebug没有安装成功。
按照教程的说法,xdebug这个扩展需要用zend的方式去加载,(至于原因大家网上查),可是就是不成功。
今天早上起来一直想着这事,于是在自己的电脑上再次安装一次。
也是先安装pear,特别一提,我的本子的环境是<span>独立安装</span>的,没有用集成。PHP的环境是5.2.10,
在安装pear的时候还发生了一件小插曲:就是他运行这个命令加载到php的扩展php_exif这个扩展的时候报了一个错误,大致信息是我没有加载mbstring这个扩展,可是这个扩展我是已经加载成功了的,而且也能在phpinfo信息页看到,后来在javaeye上看到一个帖子,提到这个问题,原来exif这个扩展需要用到mbstring,可是在php.ini中加载的循序是按照字母来的,mbstring排在了exif扩展之后,所以导致加载到exif的时候找不到mbstring,解决方法也很简单,只要把mbstring的加载提到exif的前面就可以了。重启apache然后重新安装pear,即可。
安装pear也是一样的方式安装?? go-pear,安装完成之后发现版本是1.7.1的,由于在公司安装的时候知道版本低,所以就进行了一次升级pear upgrade pear,升级到了1.9.1,然后再次安装PHPUnit,因为一直都说5的环境用的该是phpunit2而phpunit用的是4环境,于是安装
pear channel-discover pear.phpunit.de???? OK后
pear install --alldeps phpunit2
完了后我运行phpunit,发现它的选项只有8个,而且版本是2.3.6:
<img src="/static/imghwm/default1.png" data-src="/img/2012/11/07/1228552541.jpg" class="lazy" style="max-width:90%" alt="" style="max-width:90%">
觉得很奇怪,在公司安装的phpunit升级后版本是3。X的,难道我的安装有问题,于是我再次安装了一次phpunit,结果发现,我安装起来的phpunit竟然才是1.X?,太不可思议了,于是我删掉PHPunit,到了pear网站去看(<span style="color: #000000;">www.pear.php.net</span>),发现PHPunit2是2.3.6版本,于是我就卸载了phpunit,(pear uninstall phpunit),为了正确,我重新删除phpunit2重新安装,并且在安装前更新了下频道(pear update channels),然后再次安装phpunit2还是老样子,于是我就先隔着跑去安装xdebug,就是本文开篇说的那个方法再次安装。
可是我发现在我的机子上我如果xdebug的安装模式的是zend的扩展模式,apache重启竟然出现错误。于是我改成用php的扩展方式开启,
?
[Xdebug]
extension=php_xdebug.dll
xdebug.profiler_enable=on
xdebug.trace_output_dir="E:/Alicx/php/xdebug"
xdebug.profiler_output_dir="E:/Alicx/php/xdebug"
重启成功,然后执行PHPinfo,看到了xdebug扩展项:
<img src="/static/imghwm/default1.png" data-src="/img/2012/11/07/1228552542.jpg" class="lazy" alt="">?
然后我再次去命令行运行phpunit命令:
<img src="/static/imghwm/default1.png" data-src="/img/2012/11/07/1228552543.jpg" class="lazy" alt="">
发现多了coverage这几个生成覆盖率文件的选项,而且开头提示我:xdebug必须以zend的扩展方式来加载,这可怎么办呢,于是我再次开启用zend的方式加载,然后重启apache,查看error日志发现:
PHP Warning:? Xdebug MUST be loaded as a Zend extension in Unknown on line 0
PHP Fatal error:? [Zend Optimizer] Zend Optimizer 3.3.3 is incompatible with Xdebug 2.1.0 in Unknown on line 0
在javaeye找到这样一个帖子:
<strong><strong><p style="display: inline !important;"><strong><span><strong><span style="font-size: small;"><span style="font-size: 12px;">xdebug 必须使用 zend_extension_ts 或者 zend_extension 来标明它是zend的扩展</span></span></strong></span></strong></p></strong></strong>
根据 PHP 版本,zend_extension 指令可以是以下之一:
zend_extension (non ZTS, non debug build)
<span>zend_extension_ts ( ZTS, non debug build)</span>
<strong><strong><span>zend_extension_debug (non ZTS, debug build)</span></strong></strong>
<strong><span>zend_extension_debug_ts ( ZTS, debug build)</span></strong>
<strong><strong><span>ZTS:ZEND Thread Safety</span></strong></strong>
<strong><strong><span>可通过phpinfo()查看ZTS是否启用,从而决定用zend_extension还是zend_extension_ts。</span></strong></strong>
<strong><strong>extension意为基于php引擎的扩展</strong></strong>
<strong>zend_extension意为基于zend引擎的扩展</strong>
问题就在这,我的php没有启用ZEND Thread Safety,所以不能采用zend_extension_ts这个的方式加载,改用zend_extension这个加载xdebug。
重启apache,成功,再次运行phpunit:
<img src="/static/imghwm/default1.png" data-src="/img/2012/11/07/1228552544.jpg" class="lazy" alt="">
<p><span style="color: #9900ff;">接下来是错误日志:</span></p><p><span style="color: #9900ff;">PHP Fatal error:? [Zend Optimizer] Zend Optimizer 3.3.3 is incompatible with Xdebug 2.1.0 in </span></p><p><span style="color: #9900ff;">Unknown on line 0</span></p><p><span style="color: #9900ff;">难道是我安装的zend optimizer有问题,?于是我把我的zend扩展全部打上注释,然后再次用xdebug的zend扩展</span></p><p><span style="color: #9900ff;">开启</span></p><p><img src="/static/imghwm/default1.png" data-src="/img/2012/11/07/1228552545.jpg" class="lazy" alt=""></p><p><span style="max-width:90%">终于有了那三个选项,查看phpinfo也有了xdebug选项</span></p><p><span style="color: #9900ff;">分析:看来xdebug和optimization有冲突吧,上网查找,果然被我发现一篇文章中提到,确实冲突了,</span></p><p><span style="color: #9900ff;">而且还找到zend_extension的扩展只有5.3才支持,所以还是得用zend_extension_ts来扩展xdebug</span></p><p><span style="color: #9900ff;">分享该文地址:</span><span style="color: #9900ff;">http://hi.baidu.com/fykknd/blog/item/e5734e5d3960b94efbf2c0a5.html</span></p>
OK,可以用了····单元测试的覆盖率也有了,这里我就知道了,我的PHPunit2选项少时因为我没有安装其他的扩展导致单元测试的命令phpunit选项只有几个自己的,我装了xdebug之后,就有了覆盖率导出这些命令了~~~
OK,自此完成安装!!,
看来回公司我得好好看看我的xdebug的启动模式。
---本文同步发表在QQ空间:http://user.qzone.qq.com/414073277/blog/1292122868ps: QQ空间图片竟然引用不过来······

What’s still popular is the ease of use, flexibility and a strong ecosystem. 1) Ease of use and simple syntax make it the first choice for beginners. 2) Closely integrated with web development, excellent interaction with HTTP requests and database. 3) The huge ecosystem provides a wealth of tools and libraries. 4) Active community and open source nature adapts them to new needs and technology trends.

PHP and Python are both high-level programming languages that are widely used in web development, data processing and automation tasks. 1.PHP is often used to build dynamic websites and content management systems, while Python is often used to build web frameworks and data science. 2.PHP uses echo to output content, Python uses print. 3. Both support object-oriented programming, but the syntax and keywords are different. 4. PHP supports weak type conversion, while Python is more stringent. 5. PHP performance optimization includes using OPcache and asynchronous programming, while Python uses cProfile and asynchronous programming.

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

PHP remains important in the modernization process because it supports a large number of websites and applications and adapts to development needs through frameworks. 1.PHP7 improves performance and introduces new features. 2. Modern frameworks such as Laravel, Symfony and CodeIgniter simplify development and improve code quality. 3. Performance optimization and best practices further improve application efficiency.

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

PHP type prompts to improve code quality and readability. 1) Scalar type tips: Since PHP7.0, basic data types are allowed to be specified in function parameters, such as int, float, etc. 2) Return type prompt: Ensure the consistency of the function return value type. 3) Union type prompt: Since PHP8.0, multiple types are allowed to be specified in function parameters or return values. 4) Nullable type prompt: Allows to include null values and handle functions that may return null values.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Dreamweaver CS6
Visual web development tools

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Zend Studio 13.0.1
Powerful PHP integrated development environment

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool