我有一个PHP项目,文件夹结构如下:
C:UsersBasDocumentsWeb_developmentProjectsBack_endCurrentProject_nameWorkspace
我已经为这个项目安装了composer,并且已经安装了一些包
{
"name": "Bas/Project_name",
"description": "...",
"minimum-stability": "stable",
"license": "MIT",
"authors": [
{
"name": "Bas",
"email": "..."
}
],
"require": {
"psr/log": "1.0.2",
"monolog/monolog": "1.22.0",
"ip2location/ip2location-php": "8.0.2"
}
}
当我尝试安装phpunit/phpunit
版本5.7.x(最新)软件包时,它会给我[ErrorException] ZipArchive::extractTo(): Full extraction path exceed MAXPATHLEN (260)
错误。完整的错误消息看起来像:
You are running composer with xdebug enabled. This has a major impact on runtime performance. See https://getcomposer.org/xdebug
Using version ^5.7 for phpunit/phpunit
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
- Installing symfony/yaml (v3.2.1)
Loading from cache
- Installing sebastian/version (2.0.1)
Loading from cache
- Installing sebastian/resource-operations (1.0.0)
Loading from cache
- Installing sebastian/recursion-context (2.0.0)
Loading from cache
- Installing sebastian/object-enumerator (2.0.0)
Loading from cache
- Installing sebastian/global-state (1.1.1)
Loading from cache
- Installing sebastian/exporter (2.0.0)
Loading from cache
- Installing sebastian/environment (2.0.0)
Loading from cache
- Installing sebastian/diff (1.4.1)
Loading from cache
- Installing sebastian/comparator (1.2.2)
Loading from cache
- Installing doctrine/instantiator (1.0.5)
Loading from cache
- Installing phpunit/php-text-template (1.2.1)
Loading from cache
- Installing phpunit/phpunit-mock-objects (3.4.3)
Downloading: 100%
Installation failed, reverting ./composer.json to its original content.
[ErrorException]
ZipArchive::extractTo(): Full extraction path exceed MAXPATHLEN (260)
require [--dev] [--prefer-source] [--prefer-dist] [--no-progress] [--no-update] [--no-scripts] [--update-no-dev] [--update-with-dependencies] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [--sort-packages] [-o|--optimize-autoloader] [-a|--classmap-autho
ritative] [--] [<packages>]...
我正在使用composer require phpunit/phpunit
命令安装程序包。
我已经对这个问题做了一些研究,它是由一个到长的目录结构引起的,但当计算我当前的目录结构时,它只有87个字符
我已经尝试使用--prefer-source
参数运行composer install
和composer update
命令。这两个都不起作用,给了我同样的错误。
我目前运行的是Windows 10 64位。
这个问题是怎么发生的?因为我在CCD_ 7变量下有一个目录结构。
有没有办法在不改变目录结构的情况下解决这个问题?
您的路径很长。它是否太长取决于项目中目录结构的深度。
请记住,使用Composer将创建子文件夹。至少您将创建vendor/phpunit/phpunit
(22个字符),并在此基础上创建PHPUnit本身的所有子文件夹。我找到了这个路径作为示例:src/Framework/Constraint/JsonMatches/ErrorMessageProvider.php
(另外62个字符)。
添加更多的目录分隔符,我们的长度至少为87+22+62=173个字符。这比你想象的要接近260的最大值。
在拆包mock对象组件时会出现问题。我发现了这个有趣的路径:tests/MockObject/Generator/namespaced_class_implementing_interface_dont_call_parent_constructor.phpt
-101个字符。再加上供应商文件夹vendor/phpunit/phpunit-mock-objects
(36个字符)和另外两个目录分隔符,我们的长度为87+36+2+101=226个字符,越来越接近最大值。现在你只需要来自任何地方的另外34个字符,也许在开箱过程中创建了一个临时文件名,你就达到了极限。
缩短你现有的路径,它就会起作用。