title: Deploying a Symfony project with Jenkins: Best Practices
body: <p>I manage a few Symfony 2/3 projects on my Jenkins server that I am deploying to a live server. This is my current setup:</p>
  
  <h1>The build</h1>
  
  <ul>
  <li>checkout using git plugin</li>
  <li>remove database, if exists</li>
  <li>executing <code>composer install</code> (prod mode, optimize autoloader)</li>
  <li>executing <code>bower install</code> to fetch my assets</li>
  <li>executing a <code>gulp</code> build, that minifies and concatenates css / javascript (We don't use assetic)</li>
  <li>executing my database creation stuff</li>
  <li>executing unit tests</li>
  </ul>
  
  <h1>The archiving</h1>
  
  <p>After the build, I <strong>archive the artifacts</strong> of the build without the <code>vendor</code>, <code>node_modules</code> and <code>bower_components</code> folders as a zip file using the "<a href="https://wiki.jenkins-ci.org/display/JENKINS/Compress+Artifacts+Plugin">Compress Artifacts</a>" Plugin.</p>
  
  <h1>The deployment</h1>
  
  <p>I use the "<a href="https://wiki.jenkins-ci.org/display/JENKINS/Promoted+Builds+Plugin">Promoted builds</a>" plugin and the "<a href="https://wiki.jenkins-ci.org/display/JENKINS/Publish+Over+SSH+Plugin">Publish over SSH</a>" plugin in combination: If I want to "go live" with a build, I publish the artifacts (my zip file) over SSH to my live system in a directory called <code>staging_dir</code>. After the file upload, I execute some SSH commands:</p>
  
  <ul>
  <li>Set the live system to maintenance mode</li>
  <li>unzip the artifacts zip in my <code>staging_dir</code></li>
  <li>execute <code>composer install</code> on the live system (same config as during the build)</li>
  <li>(<code>bower install</code> and the <code>gulp</code> build is not necessary, as we use the assets we created during the build)</li>
  <li>migrate database</li>
  <li>move the current live system files to a <code>backup</code> folder</li>
  <li>copy over the files from the <code>staging_dir</code></li>
  <li>Set the live system to "production" mode (disable maintenance mode)</li>
  </ul>
  
  <h1>Best practices?</h1>
  
  <p>I would now like to collect some best practices for deployment:</p>
  
  <ul>
  <li>Do you prefer to transfer the <code>vendor</code> folder to the live system instead of executing <code>composer install</code> there again?</li>
  <li>What about the assets? Do you <code>bower install</code> and <code>gulp</code> build on the live system again or do you use the published assets?</li>
  <li>How do you handle your passwords when executing a live promotion?</li>
  <li>... other things I have forgotten.</li>
  </ul>