JohnnyC
JohnnyC

Reputation: 1435

Symfony2 deployement with Heroku : Dumping assets

I'm using Heroku to deploy my Symfony2 app with the default configuration but assets are not dumped.

I have added to 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"
    ]
},
...

Is it the right way ?

In the Procfile, doesn't work. And with :

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

Also doesn't work.

Thank you,

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

Upvotes: 2

Views: 288

Answers (1)

Jose Celano
Jose Celano

Reputation: 569

This works for me:

  "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"
    ]
  },

Notice "compile" section. That key name is a Heroku convention.

Symfony docs: http://symfony.com/doc/current/cookbook/deployment/heroku.html says you can use a Custom Composer Command

You do not need to add --env=prod option as you should add an environment variable in Heroku.

Upvotes: 5

Related Questions