在“;更新后cmd”;在Symfony2项目中


Running command on "post-update-cmd" in Symfony2 project

运行composer update后,我需要运行两个命令,一个是调用.sh文件的Linux控制台命令,另一个是php app/console命令。通过在composer.json文件中执行某些操作可以做到这一点吗?我注意到这几行:

"post-update-cmd": [
            "Sensio''Bundle''DistributionBundle''Composer''ScriptHandler::buildBootstrap",
            "Sensio''Bundle''DistributionBundle''Composer''ScriptHandler::clearCache",
            "Sensio''Bundle''DistributionBundle''Composer''ScriptHandler::installAssets"
        ]

但不知道这是否是正确的方式。以第一个命令:/home/data.sh和第二个命令php app/console doctrine:fixtures:load --append为例,对此有什么建议吗?

您可以将这些命令包含在post-update-cmd指令中,如下所示:

"post-update-cmd": [
    "Sensio''Bundle''DistributionBundle''Composer''ScriptHandler::buildBootstrap",
    "Sensio''Bundle''DistributionBundle''Composer''ScriptHandler::clearCache",
    "Sensio''Bundle''DistributionBundle''Composer''ScriptHandler::installAssets",
    "/home/data.sh",
    "php app/console doctrine:fixtures:load --append"
]

更多信息:https://getcomposer.org/doc/articles/scripts.md