“composer install”调用post-update-cmd而不是post-install-cmd

我有这个简单的composer.json文件。 当我运行“composer install”时,我希望它能够运行post-install-cmd脚本,但没有任何反应。 如果我将其更改为post-update-cmd,它将按预期工作。 我错过了什么吗? 是不是必须运行post-install-cmd而不是post-update-cmd?</ p>

  {
“name”:“vendorName / packageName”,
“ description“:”some description“,
”type“:”library“,
”require“:{
”psr / log“:”^ 1.1“
},
”脚本“:{
“post-install-cmd”:“$ SHELL script.sh”
}
}
</ code> </ pre>
</ div>

展开原文

原文

I have this simple composer.json file. When I run "composer install" I expect it to run post-install-cmd script but nothing happens. If I change it to post-update-cmd it works as expected. Am i missing something? Doesn't it have to run post-install-cmd instead of post-update-cmd?

{
    "name": "vendorName/packageName",
    "description": "Some description",
    "type": "library",
    "require": {
        "psr/log": "^1.1"
    },
    "scripts": {
        "post-install-cmd": "$SHELL script.sh"
    }
}

php
donglu5047
donglu5047 它在我第一次运行“composerinstall”时不存在。我正在使用“composerinit”来创建composer.json文件。我对“你想现在安装依赖项吗?”这个问题回答“否”,因为我没有使用composer.lock文件,直到我发出“composerinstall”。感谢提示。
大约一年之前 回复
duanluan8390
duanluan8390 post-install-cmd:在使用锁定文件执行install命令后发生。你有.lock文件吗?
大约一年之前 回复

1个回答



运行 composer install时调用(pre | post)-update-cmd </ code> </ 代码>如果项目的根目录中没有锁定文件</ strong>( composer.lock </ code>)。</ p>

< code> composer install </ code>命令用于在锁文件中安装依赖项。</ p>

如果没有 composer.lock </ code>,它将运行< 代码> composer update </ code>在内部解析依赖关系并为您生成锁文件。</ p>

来自 install </ code>命令的03-cli.md #install -i“rel =”nofollow noreferrer“>文档:</ p>


如果没有composer.lock文件,Composer将在依赖项解析后创建一个。 </ p>
</ blockquote>
</ div>

展开原文

原文

The (pre|post)-update-cmd is invoked when running composer install if you don't have a lock-file (composer.lock) in your project's root directory.

The composer install command is meant to install the dependencies in the lock-file.

If there is no composer.lock it will run composer update internally to resolve the dependencies and generate the lock-file for you.

From the documentation of the install command:

If there is no composer.lock file, Composer will create one after dependency resolution.

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问