Symfony2 与 Heroku 的部署:倾销资产

Joh*_*nyC 2 heroku symfony

我正在使用 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"
    ]
},
...
Run Code Online (Sandbox Code Playgroud)

这是正确的方法吗?

在 Procfile 中,不起作用。与 :

heroku run php app/console --env=prod assetic:dump
Run Code Online (Sandbox Code Playgroud)

也不起作用。

谢谢,

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

jos*_*ano 5

这对我有用:

  "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"
    ]
  },
Run Code Online (Sandbox Code Playgroud)

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

Symfony 文档:http : //symfony.com/doc/current/cookbook/deployment/heroku.html说你可以使用自定义作曲家命令

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