当前位置:Gxlcms > PHP教程 > PHPNotice:Pleasenolongerinclude解决办法_PHP教程

PHPNotice:Pleasenolongerinclude解决办法_PHP教程

时间:2021-07-01 10:21:17 帮助过:23人阅读

今天在学习Yii Framework中单元测试时,总是在运行“phpunit unit/DBTest.php”命令的时候出现以下错误,


PHP Notice: Please no longer include "PHPUnit/Framework.php". in /usr/share/php/PHPUnit/Framework.php on line 50

但自己是按照文档上说的安装了PHPUnit包了呀,后来发现想起来安装过程中由于家里网络问题其中一个依赖包出错了,但是别的包都提示安装成功了,然后自己是把那个失败的包PHP_CodeCoverage重新安装的,然后运行unit的时候就出现了上面的错误,于是自己慢慢摸索,然后做了以下步骤后,问题总算被解决了。

1. 打开pear的auto_discover选项

view plaincopy to clipboardprint?$ sudo pear config-set auto_discover 1
$ sudo pear config-set auto_discover 12. 检查已经安装的phpunit和其依赖包

view plaincopy to clipboardprint?$ sudo pear list -a
Installed packages, channel pear.phpunit.de:
============================================
Package Version State
DbUnit 1.0.3 stable
File_Iterator 1.2.6 stable
PHPUnit 3.5.15 stable
PHPUnit_MockObject 1.0.9 stable
PHPUnit_Selenium 1.0.3 stable
PHP_CodeCoverage 1.0.5 stable
PHP_Timer 1.0.2 stable
PHP_TokenStream 1.0.1 stable
Text_Template 1.1.0 stable
$ sudo pear list -a
Installed packages, channel pear.phpunit.de:
============================================
Package Version State
DbUnit 1.0.3 stable
File_Iterator 1.2.6 stable
PHPUnit 3.5.15 stable
PHPUnit_MockObject 1.0.9 stable
PHPUnit_Selenium 1.0.3 stable
PHP_CodeCoverage 1.0.5 stable
PHP_Timer 1.0.2 stable
PHP_TokenStream 1.0.1 stable
Text_Template 1.1.0 stable3. 卸载所有pear.phpunit.de channel下安装的和phpunit相关的包,这里有先后顺序,卸载的时候会有提示

view plaincopy to clipboardprint?$ sudo pear uninstall PHPUnit
$ sudo pear uninstall PHPUnit_MockObject
...
$ sudo pear uninstall PHPUnit
$ sudo pear uninstall PHPUnit_MockObject
...4. 重新安装PHPUnit包

view plaincopy to clipboardprint?$ sudo pear install pear.phpunit.de/PHPUnit
$ sudo pear install pear.phpunit.de/PHPUnit5. 再次运行“phpunit unit/DBTest.php”,问题解决。

作者“kongxx的专栏”

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/478648.htmlTechArticle今天在学习Yii Framework中单元测试时,总是在运行phpunit unit/DBTest.php命令的时候出现以下错误, PHP Notice: Please no longer include PHPUnit/Framework.p...

人气教程排行