Skip to content

[Hackday] Update Heroku doc with SYMFONY_ENV param #4545

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions cookbook/deployment/heroku.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,33 @@ change the value of ``path`` from
Once the application is deployed, run ``heroku logs --tail`` to keep the
stream of logs from Heroku open in your terminal.


Build priority in Composer
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be: Build Priority in Composer (all words should be capitialized in headings, except from closed class words)

~~~~~~~~~~~~~~~~~~~~~~~~~~

Check that you call ``clearCache`` in the end of your app build, otherwise there can be situations
when during the build you will generate hardcored links to heroku ``/tmp`` path. Typical Symfony2
build steps in ``composer.json`` should look like this:

.. code-block:: yaml

"post-install-cmd": [
"Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it really a good idea to show the complete content of the composer.json here?
this will become bad if we have to maintain this for different versions. i would prefer something like:

make sure you removed: ....
make sure you added: ....

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would indeed prefer to use ... to fold some irrelevant things.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is no longer necessary, the underlying issue is now fixed in Symfony.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this section should then be removed from this PR to avoid confusion

"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::removeSymfonyStandardFiles",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache"
],
"post-update-cmd": [
"Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::removeSymfonyStandardFiles",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache"
]

Creating a new Application on Heroku
------------------------------------

Expand Down Expand Up @@ -110,6 +137,25 @@ create the ``Procfile`` file and to add it to the repository:
[master 35075db] Procfile for Apache and PHP
1 file changed, 1 insertion(+)

Configuring Symfony to run in the prod environment
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Configuring Symfony to Run in the Production Environment"

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

If you don’t explicitly configure the environment (``dev``, ``prod`` etc)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use straight quotes here: '

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"dev, prod, etc." (missing punctation)

to use, Symfony will, by default, use the ``dev`` environment in console
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from my point of view now it becomes weird because this isn't really heroku related.
so how do we want to handle such informations for azure, platform.sh, [....]?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@timglabisch its relates only to Heroku, without this environment variable your app will fall with a error on pushing to heroku master step. Many developers have faced this problem and if this would have been indicated in official documentation it would help to save a lot of time.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is true, @mxnr, but as @timglabisch pointed out, it really should be done this way on all deploys, not just on deploys to Heroku. Otherwise, all the post-install-cmd scripts run in the dev env. @fabpot agreed that this is the right way across the board.

commands and at runtime. That would break our build, because in dev environments,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should always avoid first person usage: "That would break the build, because [...]"

Symfony uses the ``SensioGeneratorBundle``to perform certain tasks, but that bundle
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing space before "to perform"

is not installed upon a push - `Composer does not install dev packages when pushing to Heroku`_.
For Symfony to know it needs to use the ``prod`` environment at all times, it reads
from the ``SYMFONY_ENV`` environment variable. You can simply `set environment variables`_ using
the ``heroku config`` feature, so run this one command as the last step before deploying
your app for the first time:

.. code-block:: bash

$heroku config:set SYMFONY_ENV=prod
Setting config vars and restarting mighty-hamlet-1981... done, v3
SYMFONY_ENV: prod

Pushing to Heroku
~~~~~~~~~~~~~~~~~

Expand Down Expand Up @@ -193,3 +239,5 @@ You should be seeing your Symfony application in your browser.
.. _`ephemeral file system`: https://devcenter.heroku.com/articles/dynos#ephemeral-filesystem
.. _`Logplex`: https://devcenter.heroku.com/articles/logplex
.. _`verified that the RSA key fingerprint is correct`: https://devcenter.heroku.com/articles/git-repository-ssh-fingerprints
.. _`Composer does not install dev packages when pushing to Heroku`: https://devcenter.heroku.com/articles/php-support#build-behavior
.. _`set environment variables`: https://devcenter.heroku.com/articles/config-vars