【问题标题】:Symfony2 deployement with Heroku : Dumping assets使用 Heroku 部署 Symfony2:转储资产
【发布时间】:2014-12-16 09:58:01
【问题描述】:

我正在使用 Heroku 以默认配置部署我的 Symfony2 应用程序,但资产没有转储。

我已经添加到 composer.json :

...
"scripts": {
    "post-install-cmd": [
        "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
        "php app/console --env=prod assetic:dump"
    ]
},
...

方法对吗?

在 Procfile 中,不起作用。还有:

heroku run php app/console --env=prod assetic:dump

也不行。

谢谢,

参考:https://devcenter.heroku.com/articles/getting-started-with-symfony2

【问题讨论】:

  • 我认为您应该在部署之前转储您的资产。在 repo 中包含过时的文件是没有意义的,因此在提交 repo(部署)之前,您应该确保您的资产都已准备好。这是我的看法
  • 对于协作工作,我必须发送源而不是编译文件。当后端开发者推送 repo 时,他不应该在发送之前转储资产本身。我认为编译应该是自动的,但是在哪里呢?这也是我的看法;)谢谢你的帖子!

标签: symfony heroku


【解决方案1】:

这对我有用:

  "scripts": {
    "post-install-cmd": [
      "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
      "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
      "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
      "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
      "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
      "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::removeSymfonyStandardFiles",
      "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget"
    ],
    "post-update-cmd": [
      "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
      "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
      "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
      "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
      "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
      "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::removeSymfonyStandardFiles",
      "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget"
    ],
    "compile": [
      "rm web/app_dev.php",
      "php app/console assetic:dump --no-debug"
    ]
  },

注意“编译”部分。该键名是 Heroku 约定。

Symfony 文档:http://symfony.com/doc/current/cookbook/deployment/heroku.html 说你可以使用 Custom Composer Command

您不需要添加 --env=prod 选项,因为您应该在 Heroku 中添加环境变量。

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-02-04
  • 1970-01-01
  • 2019-10-27
  • 2012-11-03
  • 1970-01-01
  • 2013-06-18
  • 1970-01-01
相关资源
最近更新 更多