“钥匙:value”是什么?语法在作曲家脚本中执行
从compser文档中,您可以像这样编写脚本:
{
"scripts": {
"some-event": [
"command1",
"command2",
"command3"
],
}
}
但是在Symfony中,我发现语法略有不同,而不是列表使用键:值对:
{
"scripts": {
"auto-scripts": {
"cache:clear": "symfony-cmd",
"assets:install %PUBLIC_DIR%": "symfony-cmd"
},
},
}
此语法如何准确地工作? 它是否将命令重定向到另一个命令,在2个命令之间添加一个依赖关系?
From compser documentation you can write scripts like so:
{
"scripts": {
"some-event": [
"command1",
"command2",
"command3"
],
}
}
But in Symfony I found a slightly different syntax that instead of a list is using a key:value pair like this:
{
"scripts": {
"auto-scripts": {
"cache:clear": "symfony-cmd",
"assets:install %PUBLIC_DIR%": "symfony-cmd"
},
},
}
How does this syntax work exactly?
Does it redirect commands to another one, adds a dependency between 2 commands or what?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
该语法在作曲家中不确定。
要了解更多信息,请删除它,然后检查哪个组件断裂。然后咨询该组件的支持,以了解更多信息(和/或在此处发表评论)。
正如书面的那样,这是不确定的。至于您对作曲家的关注,您可以检查它是否被识别为脚本:
您可能会看到
auto-scripts
被列为脚本,也就是说,作曲家至少在识别自动订阅
关键字。然后,您可以执行该脚本以查看作曲家如何执行它(强烈建议您在孤立的环境中执行此操作):
要查看插件是否会有所不同,您也可以禁用插件来执行它:
请注意。
与作曲家在一起,总有
-vvv
。有关内部作曲家配置文件处理的一些注释:json文本文件(
.json
,lock
)通常被解析为关联阵列(不是stdclass :: class class class
对象)。因此,
foreach
'一个脚本成员 - 也可以是字符串,很可能是用(array)
cast进行后处理的 - 不在乎键(属性名称),只是执行脚本行。This syntax is undefined in Composer.
To learn more, remove it and then check which component(s) break(s). Then consult the support of that/these component(s) to learn more (and/or leave a comment here).
As written this is undefined. As far as you're concerned about Composer you can check if it is recognized as a script:
You'll likely see that
auto-scripts
is listed as a script, that is, Composer is recognizing at least theauto-scripts
keyword.You can then execute that script to see how Composer executes it (it is highly recommended you do this and the following in an isolated environment):
To see if a plugin would make a difference, you can also execute it with plugins disabled:
Take care.
And with Composer there is always
-vvv
.Some notes on internal Composer configuration file handling: JSON Text files (
.json
,.lock
) in Composer are typically parsed into associative arrays (notstdClass::class
objects).Therefore
foreach
'ing a script member - which can be a string as well, likely post-processed with an(array)
cast - would not care about the key (attribute name), just executing the scripts lines.该语法由
symfony/flex
插件使用,仅在auto-scripts
键下有效。Flex中的代码看起来像这样:
使用此代码处理执行:
This syntax is used by
symfony/flex
plugin and is only valid underauto-scripts
key.The code in flex looks like this:
With execute being handled using this code: