Packing and deploying Symfony web site

Question

I’m new to Symfony, coming from .NET world. Using Symfony (4) documentation, I managed to create simple web site. Now I want to put it to live, but I’m struggling to find any useful information what should I do in order to “pack” everything necessary and deploy it. Indeed, there’s page describing deployment (How to Deploy a Symfony Application), but I find it lacking information about:

  • what to include/exclude (obviously I don’t want to pack dev dependencies, and deploying composer files also doesn’t seems to make any sense)
  • what to change (there’s .env file – containing APP_ENV and APP_SECRET – where do I use those values?)
  • my hosting uses folder www for public presentation, do I have to change/configure something before renaming public directory just to www?
  • do I have to configure .htaccess to not route images/css/js trough PHP?

My current project structure is:

<pre class="lang-php prettyprint prettyprinted"><code><span class="pun">+</span><span class="pln"> bin
</span><span class="pun">+</span><span class="pln"> config
</span><span class="pun">+</span> <span class="kwd">public</span>
  <span class="pun">+</span><span class="pln"> css
  </span><span class="pun">-</span><span class="pln"> index</span><span class="pun">.</span><span class="pln">php
</span><span class="pun">+</span><span class="pln"> src
  </span><span class="pun">+</span> <span class="typ">Controller</span>
  <span class="pun">-</span> <span class="typ">Kernel</span><span class="pun">.</span><span class="pln">php
</span><span class="pun">+</span><span class="pln"> templates
</span><span class="pun">+</span> <span class="kwd">var</span>
<span class="pun">+</span><span class="pln"> vendor
</span><span class="pun">-</span> <span class="pun">.</span><span class="pln">env
</span><span class="pun">-</span> <span class="pun">.</span><span class="pln">gitignore
</span><span class="pun">-</span><span class="pln"> composer</span><span class="pun">.</span><span class="pln">json
</span><span class="pun">-</span><span class="pln"> composer</span><span class="pun">.</span><span class="kwd">lock</span>
<span class="pun">-</span><span class="pln"> symfony</span><span class="pun">.</span><span class="kwd">lock


Edit (2018-07-17):

  • I’m using git
  • hosting is capable of deploying from git branch called production (whenever I push to this branch, it calls composer install --no-dev)
  • Configuring public directory name is done in composer.json

Example of extra configuration in composer.json:


"extra"</span><span class="pun">:</span> <span class="pun">{</span>
    <span class="str">"symfony"</span><span class="pun">:</span> <span class="pun">{</span>
        <span class="str">"allow-contrib"</span><span class="pun">:</span> <span class="kwd">false</span>
    <span class="pun">},</span>
    <span class="str">"public-dir"</span><span class="pun">:</span> <span class="str">"www"</span>
<span class="pun">}


Regarding my original question – I’m now using hosting capability of deployment using git. In that case, I do need composer files as well. My original thought was to build and pack bare minimum of things and then deploy this package to server. (Now I still have bin, composer files or .gitignore(and probably even more odd things) deployed as well).

in progress 0
admin 3 months 0 Answers 157 views 0

Leave an answer

Browse
Browse

Captcha Click on image to update the captcha .