Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3f775dc

Browse files
committed
minor #6814 Created the main article about "deployment" (javiereguiluz)
This PR was merged into the 2.7 branch. Discussion ---------- Created the main article about "deployment" In the new Symfony Doc structure, top-level pages (e.g. `deployment.rst`) are "cornerstone pages" and not mere index pages listing other articles. During the doc reorganization we moved most articles, but some were missing, like this deployment article. Commits ------- 6f2ff9e Removed the "Learn more" section f3a960e Created a "Platform as a Service" section 26cee5d Fixed a reference 0515cb5 Created the main article about "deployment"
2 parents b7b13f0 + 6f2ff9e commit 3f775dc

File tree

4 files changed

+209
-214
lines changed

4 files changed

+209
-214
lines changed

_build/redirection_map

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,4 +322,5 @@
322322
/components/var_dumper/index /components/var_dumper
323323
/components/yaml/introduction /components/yaml
324324
/components/yaml/index /components/yaml
325+
/deployment/tools /deployment
325326
/install/bundles /setup/bundles

deployment.rst

Lines changed: 207 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,209 @@
1-
Deployment
2-
==========
1+
.. index::
2+
single: Deployment; Deployment tools
33

4-
.. toctree::
5-
:maxdepth: 1
6-
:glob:
4+
.. _how-to-deploy-a-symfony2-application:
75

8-
deployment/*
6+
How to Deploy a Symfony Application
7+
===================================
8+
9+
Deploying a Symfony application can be a complex and varied task depending on
10+
the setup and the requirements of your application. This article is not a step-
11+
by-step guide, but is a general list of the most common requirements and ideas
12+
for deployment.
13+
14+
.. _symfony2-deployment-basics:
15+
16+
Symfony Deployment Basics
17+
-------------------------
18+
19+
The typical steps taken while deploying a Symfony application include:
20+
21+
#. Upload your code to the production server;
22+
#. Install your vendor dependencies (typically done via Composer and may be done
23+
before uploading);
24+
#. Running database migrations or similar tasks to update any changed data structures;
25+
#. Clearing (and optionally, warming up) your cache.
26+
27+
A deployment may also include other tasks, such as:
28+
29+
* Tagging a particular version of your code as a release in your source control
30+
repository;
31+
* Creating a temporary staging area to build your updated setup "offline";
32+
* Running any tests available to ensure code and/or server stability;
33+
* Removal of any unnecessary files from the ``web/`` directory to keep your
34+
production environment clean;
35+
* Clearing of external cache systems (like `Memcached`_ or `Redis`_).
36+
37+
How to Deploy a Symfony Application
38+
-----------------------------------
39+
40+
There are several ways you can deploy a Symfony application. Start with a few
41+
basic deployment strategies and build up from there.
42+
43+
Basic File Transfer
44+
~~~~~~~~~~~~~~~~~~~
45+
46+
The most basic way of deploying an application is copying the files manually
47+
via FTP/SCP (or similar method). This has its disadvantages as you lack control
48+
over the system as the upgrade progresses. This method also requires you
49+
to take some manual steps after transferring the files (see `Common Post-Deployment Tasks`_)
50+
51+
Using Source Control
52+
~~~~~~~~~~~~~~~~~~~~
53+
54+
If you're using source control (e.g. Git or SVN), you can simplify by having
55+
your live installation also be a copy of your repository. When you're ready
56+
to upgrade it is as simple as fetching the latest updates from your source
57+
control system.
58+
59+
This makes updating your files *easier*, but you still need to worry about
60+
manually taking other steps (see `Common Post-Deployment Tasks`_).
61+
62+
Using Platforms as a Service
63+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
64+
65+
The specific deployment steps vary greatly from one service provider to another,
66+
so check out the dedicated article for the service of your choose:
67+
68+
* :doc:`Microsoft Azure </deployment/azure-website>`
69+
* :doc:`Heroku </deployment/heroku>`
70+
* :doc:`Platform.sh </deployment/platformsh>`
71+
* :doc:`fortrabbit </deployment/fortrabbit>`
72+
73+
Using Build Scripts and other Tools
74+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
75+
76+
There are also tools to help ease the pain of deployment. Some of them have been
77+
specifically tailored to the requirements of Symfony.
78+
79+
`Capistrano`_ with `Symfony plugin`_
80+
`Capistrano`_ is a remote server automation and deployment tool written in Ruby.
81+
`Symfony plugin`_ is a plugin to ease Symfony related tasks, inspired by `Capifony`_
82+
(which works only with Capistrano 2 )
83+
84+
`sf2debpkg`_
85+
Helps you build a native Debian package for your Symfony project.
86+
87+
`Magallanes`_
88+
This Capistrano-like deployment tool is built in PHP, and may be easier
89+
for PHP developers to extend for their needs.
90+
91+
`Fabric`_
92+
This Python-based library provides a basic suite of operations for executing
93+
local or remote shell commands and uploading/downloading files.
94+
95+
`Deployer`_
96+
This is another native PHP rewrite of Capistrano, with some ready recipes for
97+
Symfony.
98+
99+
Bundles
100+
There are some `bundles that add deployment features`_ directly into your
101+
Symfony console.
102+
103+
Basic scripting
104+
You can of course use shell, `Ant`_ or any other build tool to script
105+
the deploying of your project.
106+
107+
Common Post-Deployment Tasks
108+
----------------------------
109+
110+
After deploying your actual source code, there are a number of common things
111+
you'll need to do:
112+
113+
A) Check Requirements
114+
~~~~~~~~~~~~~~~~~~~~~
115+
116+
Check if your server meets the requirements by running:
117+
118+
.. code-block:: bash
119+
120+
$ php app/check.php
121+
122+
B) Configure your ``app/config/parameters.yml`` File
123+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
124+
125+
This file should *not* be deployed, but managed through the automatic utilities
126+
provided by Symfony.
127+
128+
C) Install/Update your Vendors
129+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
130+
131+
Your vendors can be updated before transferring your source code (i.e.
132+
update the ``vendor/`` directory, then transfer that with your source
133+
code) or afterwards on the server. Either way, just update your vendors
134+
as you normally do:
135+
136+
.. code-block:: bash
137+
138+
$ composer install --no-dev --optimize-autoloader
139+
140+
.. tip::
141+
142+
The ``--optimize-autoloader`` flag improves Composer's autoloader performance
143+
significantly by building a "class map". The ``--no-dev`` flag ensures that
144+
development packages are not installed in the production environment.
145+
146+
.. caution::
147+
148+
If you get a "class not found" error during this step, you may need to
149+
run ``export SYMFONY_ENV=prod`` before running this command so that
150+
the ``post-install-cmd`` scripts run in the ``prod`` environment.
151+
152+
D) Clear your Symfony Cache
153+
~~~~~~~~~~~~~~~~~~~~~~~~~~~
154+
155+
Make sure you clear (and warm-up) your Symfony cache:
156+
157+
.. code-block:: bash
158+
159+
$ php app/console cache:clear --env=prod --no-debug
160+
161+
E) Dump your Assetic Assets
162+
~~~~~~~~~~~~~~~~~~~~~~~~~~~
163+
164+
If you're using Assetic, you'll also want to dump your assets:
165+
166+
.. code-block:: bash
167+
168+
$ php app/console assetic:dump --env=prod --no-debug
169+
170+
F) Other Things!
171+
~~~~~~~~~~~~~~~~
172+
173+
There may be lots of other things that you need to do, depending on your
174+
setup:
175+
176+
* Running any database migrations
177+
* Clearing your APC cache
178+
* Running ``assets:install`` (already taken care of in ``composer install``)
179+
* Add/edit CRON jobs
180+
* Pushing assets to a CDN
181+
* ...
182+
183+
Application Lifecycle: Continuous Integration, QA, etc
184+
------------------------------------------------------
185+
186+
While this entry covers the technical details of deploying, the full lifecycle
187+
of taking code from development up to production may have a lot more steps
188+
(think deploying to staging, QA (Quality Assurance), running tests, etc).
189+
190+
The use of staging, testing, QA, continuous integration, database migrations
191+
and the capability to roll back in case of failure are all strongly advised. There
192+
are simple and more complex tools and one can make the deployment as easy
193+
(or sophisticated) as your environment requires.
194+
195+
Don't forget that deploying your application also involves updating any dependency
196+
(typically via Composer), migrating your database, clearing your cache and
197+
other potential things like pushing assets to a CDN (see `Common Post-Deployment Tasks`_).
198+
199+
.. _`Capifony`: http://capifony.org/
200+
.. _`Capistrano`: http://capistranorb.com/
201+
.. _`sf2debpkg`: https://github.com/liip/sf2debpkg
202+
.. _`Fabric`: http://www.fabfile.org/
203+
.. _`Magallanes`: https://github.com/andres-montanez/Magallanes
204+
.. _`Ant`: http://blog.sznapka.pl/deploying-symfony2-applications-with-ant
205+
.. _`bundles that add deployment features`: http://knpbundles.com/search?q=deploy
206+
.. _`Memcached`: http://memcached.org/
207+
.. _`Redis`: http://redis.io/
208+
.. _`Symfony plugin`: https://github.com/capistrano/symfony/
209+
.. _`Deployer`: http://deployer.org/

deployment/azure-website.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ MySQL database.
392392
393393
This command builds the tables and indexes for your MySQL database. If your
394394
Symfony application is more complex than a basic Symfony Standard Edition, you
395-
may have additional commands to execute for setup (see :doc:`/deployment/tools`).
395+
may have additional commands to execute for setup (see :doc:`/deployment`).
396396

397397
Make sure that your application is running by browsing the ``app.php`` front
398398
controller with your web browser and the following URL:

0 commit comments

Comments
 (0)