热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

无法在包含路径phpstorm中找到PHPUnit。-CannotfindPHPUnitinincludepathphpstorm

CannotfindPHPUnitinincludepathistheerrormessageIgetwhenItrytorunmycodeinphpstorm

Cannot find PHPUnit in include path is the error message I get when I try to run my code in phpstorm.

在include路径中找不到PHPUnit是我在phpstorm中运行代码时得到的错误消息。

In the PHP Settings, my PHP level language is 5.4 (traits, short array syntax, etc.) and interpreter is Name(5.4.7) where Name is user defined.

在PHP设置中,我的PHP级别语言是5.4(特征、短数组语法等),解释器是Name(5.4.7),其中Name是用户定义的。

The error appears when I try to run the code and the exact message is this:

当我试图运行代码时出现错误,确切的消息是:

C:\xampp2\php\php.exe C:\Users\DELL\AppData\Local\Temp\ide-phpunit.php --no-configuration

C:\ php xampp2 \ php \。exe C:\Users\DELL\AppData\Local\Temp\ ide-phpunit。php——了无配置

C:\xampp2\htdocs\ft-website

C:\ xampp2 \根\ ft-website

Testing started at 2:34 PM ...

测试从下午2:34开始……

Process finished with exit code 1

使用退出代码1完成进程

Cannot find PHPUnit in include path (.;C:\xampp2\php\PEAR)`

无法在包含路径(.;C:\xampp2\php\PEAR)中找到PHPUnit。

5 个解决方案

#1


48  

Just encountered this problem myself.

我自己也遇到过这个问题。

I'm unsure why it is unable to find PHPUnit in the include path (despite the fact that it is there, albeit in all lowercase).

我不确定为什么它不能在include路径中找到PHPUnit(尽管它确实存在,尽管是小写的)。

I got around this by changing my IntelliJ Preferences for PHPUnit (under PHP --> PHPUnit). I changed the PHPUnit library settings to Use custom loader and then specified the path to the phpunit executable. On my mac, that was /usr/local/Cellar/php54/5.4.26/bin/phpunit.

我通过更改PHPUnit的IntelliJ首选项(在PHP下——> PHPUnit)来解决这个问题。我将PHPUnit库设置更改为使用自定义加载程序,然后指定到PHPUnit可执行文件的路径。在我的mac上,那是/usr/ local/cellar/php54 /5.4.26/ bin/phpunitit。

UPDATE:

更新:

I just discovered that pear now installs PHPUnit as a phar named phpunit. It previously installed the PHPUnit source, which was really nice for reference and code completion in PHPStorm. I think that this is the reason things aren't working any longer with PHPStorm, because it's expecting a php executable and not a php archive.

我刚刚发现pear现在将PHPUnit安装为PHPUnit。它之前安装了PHPUnit源代码,这对于PHPStorm中的引用和代码完成是非常好的。我认为这就是PHPStorm不能工作的原因,因为它需要的是php可执行文件而不是php归档文件。

So, I'm moving away from using pear to install PHPUnit, and I'm using composer instead. This bundles PHPUnit directly as a dependency of my project, which makes it more portable than a system dependency. You'll need to add vendor/phpunit/phpunit as a PHP include path in your PHPStorm preferences. This will serve two purposes:

因此,我不再使用pear来安装PHPUnit,而是使用composer。这将PHPUnit直接打包为我的项目的依赖项,这使得它比系统依赖项更具可移植性。您将需要添加供应商/phpunit/phpunit作为PHP包含路径的PHPStorm首选项。这将达到两个目的:

  1. PHPStorm can find the phpunit executable now
  2. PHPStorm现在可以找到phpunit可执行文件
  3. PHPStorm will index all the PHPUnit classes now, so you'll get auto-complete. Yay!
  4. PHPStorm将会索引所有的PHPUnit类,所以你会自动完成。耶!

To do this, go to Languages and Frameworks in the PhpStorm settings. If you click on PHP, on the right you have your include paths

为此,请转到PhpStorm设置中的语言和框架。如果你点击PHP,在右边你有你的包含路径

#2


17  

I had this problem after adding PHPUnit via composer.

我在通过composer添加PHPUnit后遇到了这个问题。

I fixed this by choosing use custom autoloader in Settings -> Languages and Frameworks -> PHP -> PHPUnit, then adding /vendor/autoload.php as the location of the custom autoloader.

我在设置中选择了使用自定义的autoloader ->语言和框架-> PHP -> PHPUnit,然后添加/vendor/autoload。php作为自定义自动加载程序的位置。

#3


4  

This is the way to do it without using composer, and using your global phpunit.

这是一种无需使用composer和全局phpunit的方法。

  1. Phpunit now comes with a phar file. My path was /usr/local/Cellar/phpunit/5.0.0/libexec/phpunit-5.0.0.phar
  2. Phpunit现在带有phar文件。我的道路是/usr/local/Cellar/phpunit/5.0.0/libexec/phpunit-5.0.0.phar

enter image description here

  1. PhpStorm Preferences -> Path to phpunit.phar -> select the phpunit phar
  2. PhpStorm首选项-到phpunit的>路径。phar ->选择phpunit phar

enter image description here

  1. That's all, good stuff.
  2. 这些都是好东西。

#4


3  

In addition to Ben's answer, in phpStorm 7.1.3 it works by specifying the phpunit.phar location under the "use custom loader" option, for example:

除了Ben的答案之外,在phpStorm 7.1.3中,它通过指定phpunit来工作。“使用自定义加载程序”选项下的phar位置,例如:

"Path to script: /usr/share/php/phpunit.phar"

“脚本路径:/usr/share/php/phpunit.phar”

#5


2  

I had this same problem for PHPStorm 2017 using Vagrant. First go to Settings -> Languages and Frameworks -> PHP and Add a remote interpreter, then go to Settings -> Languages and Frameworks -> PHP -> PHPUnit click the + on top and click by Remote Interpreter. If you're using Composer autoloader, then enter your full Vagrant path to your autoloader file.

我在2017年的PHPStorm上遇到了同样的问题。首先进入设置——>语言和框架——> PHP并添加一个远程解释器,然后进入设置——>语言和框架——> PHP -> PHPUnit点击上面的+,然后通过远程解释器点击。如果您正在使用Composer autoloader,那么请输入您的完整的流浪路径到您的autoloader文件。


推荐阅读
  • Iamtryingtomakeaclassthatwillreadatextfileofnamesintoanarray,thenreturnthatarra ... [详细]
  • 本文介绍了如何使用PHP向系统日历中添加事件的方法,通过使用PHP技术可以实现自动添加事件的功能,从而实现全局通知系统和迅速记录工具的自动化。同时还提到了系统exchange自带的日历具有同步感的特点,以及使用web技术实现自动添加事件的优势。 ... [详细]
  • Java序列化对象传给PHP的方法及原理解析
    本文介绍了Java序列化对象传给PHP的方法及原理,包括Java对象传递的方式、序列化的方式、PHP中的序列化用法介绍、Java是否能反序列化PHP的数据、Java序列化的原理以及解决Java序列化中的问题。同时还解释了序列化的概念和作用,以及代码执行序列化所需要的权限。最后指出,序列化会将对象实例的所有字段都进行序列化,使得数据能够被表示为实例的序列化数据,但只有能够解释该格式的代码才能够确定数据的内容。 ... [详细]
  • 如何用UE4制作2D游戏文档——计算篇
    篇首语:本文由编程笔记#小编为大家整理,主要介绍了如何用UE4制作2D游戏文档——计算篇相关的知识,希望对你有一定的参考价值。 ... [详细]
  • 1,关于死锁的理解死锁,我们可以简单的理解为是两个线程同时使用同一资源,两个线程又得不到相应的资源而造成永无相互等待的情况。 2,模拟死锁背景介绍:我们创建一个朋友 ... [详细]
  • 本文介绍了自动化测试专家Elfriede Dustin在2008年的文章中讨论了自动化测试项目失败的原因。同时,引用了IDT在2007年进行的一次软件自动化测试的研究调查结果,调查显示很多公司认为自动化测试很有用,但很少有公司成功实施。调查结果表明,缺乏资源是导致自动化测试失败的主要原因,其中37%的人认为缺乏时间。 ... [详细]
  • 在Oracle11g以前版本中的的DataGuard物理备用数据库,可以以只读的方式打开数据库,但此时MediaRecovery利用日志进行数据同步的过 ... [详细]
  • Nginx使用AWStats日志分析的步骤及注意事项
    本文介绍了在Centos7操作系统上使用Nginx和AWStats进行日志分析的步骤和注意事项。通过AWStats可以统计网站的访问量、IP地址、操作系统、浏览器等信息,并提供精确到每月、每日、每小时的数据。在部署AWStats之前需要确认服务器上已经安装了Perl环境,并进行DNS解析。 ... [详细]
  • vue使用
    关键词: ... [详细]
  • 本文介绍了brain的意思、读音、翻译、用法、发音、词组、同反义词等内容,以及脑新东方在线英语词典的相关信息。还包括了brain的词汇搭配、形容词和名词的用法,以及与brain相关的短语和词组。此外,还介绍了与brain相关的医学术语和智囊团等相关内容。 ... [详细]
  • 向QTextEdit拖放文件的方法及实现步骤
    本文介绍了在使用QTextEdit时如何实现拖放文件的功能,包括相关的方法和实现步骤。通过重写dragEnterEvent和dropEvent函数,并结合QMimeData和QUrl等类,可以轻松实现向QTextEdit拖放文件的功能。详细的代码实现和说明可以参考本文提供的示例代码。 ... [详细]
  • [译]技术公司十年经验的职场生涯回顾
    本文是一位在技术公司工作十年的职场人士对自己职业生涯的总结回顾。她的职业规划与众不同,令人深思又有趣。其中涉及到的内容有机器学习、创新创业以及引用了女性主义者在TED演讲中的部分讲义。文章表达了对职业生涯的愿望和希望,认为人类有能力不断改善自己。 ... [详细]
  • 本文讨论了一个关于cuowu类的问题,作者在使用cuowu类时遇到了错误提示和使用AdjustmentListener的问题。文章提供了16个解决方案,并给出了两个可能导致错误的原因。 ... [详细]
  • Go语言实现堆排序的详细教程
    本文主要介绍了Go语言实现堆排序的详细教程,包括大根堆的定义和完全二叉树的概念。通过图解和算法描述,详细介绍了堆排序的实现过程。堆排序是一种效率很高的排序算法,时间复杂度为O(nlgn)。阅读本文大约需要15分钟。 ... [详细]
  • 深入理解Kafka服务端请求队列中请求的处理
    本文深入分析了Kafka服务端请求队列中请求的处理过程,详细介绍了请求的封装和放入请求队列的过程,以及处理请求的线程池的创建和容量设置。通过场景分析、图示说明和源码分析,帮助读者更好地理解Kafka服务端的工作原理。 ... [详细]
author-avatar
aguiladesilvo_502
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有