使用作曲家无需报价

发布于 2025-02-13 19:27:17 字数 477 浏览 0 评论 0原文

为什么

composer require symfony/symfony ~4.4

安装SYMFONY 4.4.43(截至2022年7月6日),并

composer require symfony/symfony ^4.4

安装Symfony 4.4.0(不是我要求的),并

composer require symfony/symfony 4.4

安装Symfony 4.4.0(明智的默认值),但

composer require symfony/symfony "^4.4"

安装了Symfony的最新版本4.4.43 (应该应该)?

我的平台是Windows 10,使用命令提示符。

为什么作曲家需要双引号才能识别^字符?

Why does

composer require symfony/symfony ~4.4

install Symfony 4.4.43 (as of 6 July 2022), and

composer require symfony/symfony ^4.4

installs Symfony 4.4.0 (not what I asked for), and

composer require symfony/symfony 4.4

installs Symfony 4.4.0 (sensible default), but

composer require symfony/symfony "^4.4"

installs the latest version of Symfony 4.4.43 (as it should)?

My platform is Windows 10, using the command prompt.

Why are the double quotes needed for Composer to recognise the ^ character?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

小伙你站住 2025-02-20 19:27:17

为什么作曲家需要双引号才能识别^字符?

因为^在命令提示符上具有特殊的含义,所以它(caret“ ^”)是 逃脱字符 wp> wp 在Windows命令提示中,请注意:

我的平台是Windows 10,使用命令提示。

不幸的是 caret ^具有版本约束的特殊含义(比较 caret版本范围作曲家 以及NPM/YARN等),因此角色也需要逃脱。

一种方法是引用该值以删除命令行上的特殊含义,然后它已经尝试了您自己的尝试:

composer require symfony/symfony "^4.4"

因此,Windows上较短的答案是:引用版本以COMPOSER的方式引用双引号中的限制使潜在的caret ^传递给Composer命令verbatim:“^4.4”

顺便提一句。 Linux命令提示符也是如此类似的情况,tilde 字符可以具有特殊的含义(用户 s s home 目录)在命令行参数的开头。在这里再次引用双引号的引用可防止具有特殊含义:“ 〜4.4.0”(比较 tilde版本范围作曲家 )。

Why are the double quotes needed for Composer to recognise the ^ character?

Because the ^ has special meaning on the command prompt, it (the caret "^") is the escape character WP on the Windows command prompt, mind:

My platform is Windows 10, using the command prompt.

Unfortunately the caret ^ has as well special meaning for the version constraint (compare Caret Version Range Composer as well as for NPM/YARN etc.) so the character needs to be escape as well.

One way to do this is to quote the value to remove the special meaning on the commandline and then it works as you have tried yourself already:

composer require symfony/symfony "^4.4"

So the shorter answer on windows is: Quote the version constrain in double quotes with composer require so that a potential caret ^ gets passed to the Composer command verbatim: "^4.4".

Btw. something similar is the case on a Linux command prompt, the tilde ~ character can have special meaning (path to the USERs HOME directory) when at the beginning of a command line argument. Here again quoting in double quotes prevents having the special meaning: "~4.4.0" (compare Tilde Version Range Composer).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文