As recommanded by the Symfony2 documentation
you shoud not put “parameters.ini” or “parameters.yml” file under version
control. This cookbook will show you a way to automatically upload your
parameters file during your deployment process.
The easy way
Single stage
You can just copy and paste the snippet code below inside your deploy.rb file
replacing the origin_file value with yours (i.e. for Symfony 2.0.* replace
parameters.yml by parameters.ini).
Unshared parameters files:
Shared parameters files:
Multistage
You can also have multiple stages each having their own parameters file. To
accomplish this task you can also setup an automatic upload of parameters
files. For this example we are assuming that all your parameters files are
located on an app/config/parameters folder which contains parameters_prod.yml
and parameters_staging.yml files.
You can then use the same snippets as described in the previous part and past
it on you staging.rb and prod.rb files replacing the origin_file variable
if needed.
In case of a shared parameters file:
In case of an unshared parameters file:
The cleaner way
In the previous section we saw how to process this task easily but it needs
a lot of copy and paste in case of multistage usage. This second method is
a simple implementation that you can simply throw in your deploy.rb then you’ll
just need to override variables in each of your stage specific *.rb files.
Then you have to choose when to trigger this task. For that you’ll copy the
corresponding line right after the previous task.
For a shared parameters file: after 'deploy:setup', 'upload_parameters'
For an unshared parameters file: before 'deploy:share_childs', 'upload_parameters'
NOTE: In case of a shared parameters file, the upload of the file will occur
during the deployement setup phase, while for an unshared parameters file the
upload will occur every time you run your deploy task.
Then you can specify the right parameters file for each stage.
For the prod.rb file:
For the staging.rb file:
Found a typo? Something is wrong in this documentation? Just fork and edit it !