尝试使用 Composer 安装 Quickbooks API 时出现 "failed to open stream: no such file or directory" 错误

When trying to install Quickbooks API with Composer I get a "failed to open stream: no such file or directory" error

我正在尝试使用 composer 安装 quickbooks API v3。当我使用命令时:

composer require quickbooks/v3-php-sdk

我回来了:

Using version ^3.2 for quickbooks/v3-php-sdk
./composer.json has been created
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
  - Installing quickbooks/v3-php-sdk (v3.2.3): Downloading (100%)

Installation failed, deleting ./composer.json.
  [ErrorException]
  ZipArchive::extractTo(c:\Dropbox\Projects\Web\Websites\Instamation\wwwincludes/vendor/composer/034a1449/intuit-QuickBooks-V3-PHP-SDK-b501
  2d0\src\XSD2PHP\test\data\expected\ContactCompany\oasis\names\specification\ubl\schema\xsd\CommonAggregateComponents_2/AdditionalItemProp
  erty.php): failed to open stream: No such file or directory

经过一些研究,我尝试 运行 这些命令,但结果没有任何不同:

composer clear-cache

composer dump-autoload

composer dump-autoload -o

composer update

我注意到路径中同时有正斜线和反斜线,这看起来很奇怪。知道是什么导致了这个错误吗?

因为我的第一个遮阳篷没用, 尝试:

作曲家要求'。 $_SERVER['DOCUMENT_ROOT'] 。 '/quickbooks/v3-php-sdk';

您还必须将其移动到文档根目录或文档根目录上的文件夹。因为那是网络服务器只能在那里访问的地方。

看起来像是路径问题。路径太长。 Composer 抱怨路径对于 Windows 上的 PHP 来说太长了。 Windows 的最大路径长度 (MAXPATHLEN) 为 260 个字符,此处类似示例:composer/composer#3755。

如果您不超过 260 (https://msdn.microsoft.com/en-gb/library/windows/desktop/aa365247(v=vs.85).aspx#maxpath),您可以重命名您的项目以绕过相对简单的限制 "fix"。

您的错误代码: ZipArchive::extractTo(c:\Dropbox\Projects\Web\Websites\Instamation\wwwincludes/vendor/composer/034a1449/intuit-QuickBooks-V3-PHP-SDK-b501 2d0\src\XSD2PHP\test\data\expected\ContactCompany\oasis\names\specification\ubl\schema\xsd\CommonAggregateComponents_2/AdditionalItemProp erty.php): failed to open stream: No such file or directory

因为 wwwincludes/vendor/composer/034a1449/intuit-QuickBooks-V3-PHP-SDK-b5012d0 是在 php/apache 环境中生成的路径,它将指向 phpini 文件中的 include_path = 语句。

所以我会尝试更改 php.ini 文件中包含路径的斜杠。

如果您正在为 composer 调试此程序,请安装一个例程,该例程将调用 realpath() 以更正错误配置的 php 路径以免导致错误。

我在 cmd 提示符下 运行 此命令 composer require quickbooks/v3-php-sdk 时遇到此错误。

Failed to download quickbooks/v3-php-sdk from dist: The archive may contain identical file names with different capitalization (which fails on case insensitive filesystems): ZipArchive::extractTo(): Full extraction path exceed MAXPATHLEN (260)

然后我把我的项目名改小了,去掉了项目名中的'-',最后我安装成功了。