我有一个PHP项目,文件夹结构如下:
C:\Users\Bas\Documents\Web_development\Projects\Back_end\Current\Project_name\Workspace
我为这个项目安装了composer,并且已经安装了一些包。我的composer.json看起来像这样:
{
"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个字符。
我尝试使用composer install
参数运行composer update
和--prefer-source
命令。这两个都没有用,给了我同样的错误。
我目前正在运行Windows 10 64位。
这个问题是怎么发生的?因为我在MAXPATHLEN (260)
变量下有一个目录结构。
有没有办法解决这个问题而不改变我的目录结构?
答案 0 :(得分:2)
你的道路漫长。是否太长取决于项目中目录结构的深度。
请记住,使用Composer会创建子文件夹。至少你要创建vendor/phpunit/phpunit
(22个字符),并在这个PHPUnit本身的所有子文件夹之上。我发现这条路径是一个例子:src/Framework/Constraint/JsonMatches/ErrorMessageProvider.php
(另外62个字符)。
添加更多目录分隔符,我们至少有87 + 22 + 2 + 62 = 173个字符长。这比你想象的那样接近260的最大值。
解压缩模拟对象组件时出现问题。我找到了这条有趣的道路: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个字符,也许在解包时会创建一个临时文件名,并且你达到了极限。
缩短现有路径,它会起作用。