Fatal error: require_once(): Failed opening required 'PHPUnit/Autoload.php'

Fatal error: require_once(): Failed opening required 'PHPUnit/Autoload.php'

我使用的 php 代码包含:

require_once 'PHPUnit/Autoload.php';
include 'vendor/autoload.php';

这个 php 文件 运行 在 localhost 上使用 XAMPP 非常完美,但是当我尝试 运行 自己 共享主机 服务器出现此错误:

Fatal error: require_once(): Failed opening required 'PHPUnit/Autoload.php' (include_path='.:/usr/lib/php:/usr/local/lib/php')


A PHP Error was encountered

Severity: Compile Error

Message: require_once(): Failed opening required 'PHPUnit/Autoload.php' (include_path='.:/usr/lib/php:/usr/local/lib/php')

如有任何帮助,我们将不胜感激

您似乎在本地安装了一个非常旧的 pear 版本的 PHPUnit。 deprecated 好久了。相反,您需要将 phpunit 添加到 composer.json:

{
    "require-dev": {
        "phpunit/phpunit": "5.0.*" //or whatever version you need
    }
}