Skip to content

Commit 60c85de

Browse files
committed
Merge branch '2.0' into 2.1
2 parents ecdc8ea + 2f9cfb6 commit 60c85de

File tree

5 files changed

+201
-2
lines changed

5 files changed

+201
-2
lines changed

components/dependency_injection/tags.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,8 @@ run when the container is compiled::
168168

169169
.. note::
170170

171-
Compiler passes are registered differently is you are using the full
172-
stack framework, see :doc:`/cookbook/service_container/compiler_passes`
171+
Compiler passes are registered differently if you are using the full
172+
stack framework. See :doc:`/cookbook/service_container/compiler_passes`
173173
for more details.
174174

175175
Adding additional attributes on Tags

cookbook/deployment-tools.rst

Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
.. index::
2+
single: Deployment
3+
4+
Deploying a Symfony2 Application
5+
================================
6+
7+
.. note::
8+
9+
Deploying can be a complex and varied task depending on your setup and needs.
10+
This entry doesn't try to explain everything, but rather offers the most
11+
common requirements and ideas for deployment.
12+
13+
Symfony2 Deployment Basics
14+
--------------------------
15+
16+
The typical steps taken while deploying a Symfony2 application include:
17+
18+
#. Upload your modified code to the live server;
19+
#. Update your vendor dependencies (typically done via ``bin/vendors``, and may
20+
be done before uploading);
21+
#. Running database migrations or similar tasks to update any changed data structures;
22+
#. Clearing (and perhaps more importantly, warming up) your cache.
23+
24+
A deployment may also include other things, such as:
25+
26+
* Tagging a particular version of of your code as a release in your source control repository;
27+
* Creating a temporary staging area to build your updated setup "offline";
28+
* Running any tests available to ensure code and/or server stability;
29+
* Removal of any unnecessary files from ``web`` to keep your production environment clean;
30+
* Clearing of external cache systems (like `Memcached`_ or `Redis`_).
31+
32+
How to deploy a Symfony2 application
33+
------------------------------------
34+
35+
There are several ways you can deploy a Symfony2 application.
36+
37+
Let's start with a few basic deployment strategies and build up from there.
38+
39+
Basic File Transfer
40+
~~~~~~~~~~~~~~~~~~~
41+
42+
The most basic way of deploying an application is copying the files manually
43+
via ftp/scp (or similar method). This has its disadvantages as you lack control
44+
over the system as the upgrade progresses. This method also requires you
45+
to take some manual steps after transferring the files (see `Common Post-Deployment Tasks`_)
46+
47+
Using Source Control
48+
~~~~~~~~~~~~~~~~~~~~
49+
50+
If you're using source control (e.g. git or svn), you can simplify by having
51+
your live installation also be a copy of your repository. When you're ready
52+
to upgrade it is as simple as fetching the latest updates from your source
53+
control system.
54+
55+
This makes updating your files *easier*, but you still need to worry about
56+
manually taking other steps (see `Common Post-Deployment Tasks`_).
57+
58+
Using Build scripts and other Tools
59+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
60+
61+
There are also high-quality tools to help ease the pain of deployment. There
62+
are even a few tools which have been specifically tailored to the requirements of
63+
Symfony2, and which take special care to ensure that everything before, during,
64+
and after a deployment has gone correctly.
65+
66+
See `The Tools`_ for a list of tools that can help with deployment.
67+
68+
Common Post-Deployment Tasks
69+
----------------------------
70+
71+
After deploying your actual source code, there are a number of common things
72+
you'll need to do:
73+
74+
A) Configure your ``app/config/parameters.ini`` file
75+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
76+
77+
This file should be customized on each system. The method you use to
78+
deploy your source code should *not* deploy this file. Instead, you should
79+
set it up manually (or via some build process) on your server(s).
80+
81+
B) Update your vendors
82+
~~~~~~~~~~~~~~~~~~~~~~
83+
84+
Your vendors can be updated before transferring your source code (i.e.
85+
update the ``vendor/`` directory, then transfer that with your source
86+
code) or afterwards on the server. Either way, just update your vendors
87+
as your normally do:
88+
89+
.. code-block:: bash
90+
91+
$ php bin/vendors install
92+
93+
C) Clear your Symfony cache
94+
~~~~~~~~~~~~~~~~~~~~~~~~~~~
95+
96+
Make sure you clear (and warm-up) your Symfony cache:
97+
98+
.. code-block:: bash
99+
100+
$ php app/console cache:clear --env=prod --no-debug
101+
102+
D) Other things!
103+
~~~~~~~~~~~~~~~~
104+
105+
There may be lots of other things that you need to do, depending on your
106+
setup:
107+
108+
* Running any database migrations
109+
* Clearing your APC cache
110+
* Dumping your Assetic assets (taken care of already in ``cache:clear``)
111+
* Running ``assets:install`` (taken care of already in ``bin/vendors``)
112+
* Add/edit CRON jobs
113+
* Pushing assets to a CDN
114+
* ...
115+
116+
Application Lifecycle: Continuous Integration, QA, etc
117+
------------------------------------------------------
118+
119+
While this entry covers the technical details of deploying, the full lifecycle
120+
of taking code from development up to production may have a lot more steps
121+
(think deploying to staging, QA, running tests, etc).
122+
123+
The use of staging, testing, QA, continuous integration, database migrations
124+
and the capability to roll back in case of failure are all strongly advised. There
125+
are simple and more complex tools and one can make the deployment as easy
126+
(or sophisticated) as your environment requires.
127+
128+
Don't forget that deploying your application also involves updating any dependency
129+
(typically via ``bin/vendors``), migrating your database, clearing your cache and
130+
other potential things like pushing assets to a CDN (see `Common Post-Deployment Tasks`_).
131+
132+
The Tools
133+
---------
134+
135+
`Capifony`_:
136+
137+
This tool provides a specialized set of tools on top of Capistrano, tailored
138+
specifically to symfony and Symfony2 projects.
139+
140+
`sf2debpkg`_:
141+
142+
This tool helps you build a native Debian package for your Symfony2 project.
143+
144+
`Magallanes`_:
145+
146+
This Capistrano-like deployment tool is built in PHP, and may be easier
147+
for PHP developers to extend for their needs.
148+
149+
Bundles:
150+
151+
There are many `bundles that add deployment features`_ directly into your
152+
Symfony2 console.
153+
154+
Basic scripting:
155+
156+
You can of course use shell, `Ant`_, or any other build tool to script
157+
the deploying of your project.
158+
159+
Platform as a Service Providers:
160+
161+
PaaS is a relatively new way to deploy your application. Typically a PaaS
162+
will use a single configuration file in your project's root directory to
163+
determine how to build an environment on the fly that supports your software.
164+
One provider with confirmed Symfony2 support is `PagodaBox`_.
165+
166+
.. tip::
167+
168+
Looking for more? Talk to the community on the `Symfony IRC channel`_ #symfony
169+
(on freenode) for more information.
170+
171+
.. _`Capifony`: https://capifony.org/
172+
.. _`sf2debpkg`: https://github.com/liip/sf2debpkg
173+
.. _`Ant`: http://blog.sznapka.pl/deploying-symfony2-applications-with-ant
174+
.. _`PagodaBox`: https://github.com/jmather/pagoda-symfony-sonata-distribution/blob/master/Boxfile
175+
.. _`Magallanes`: https://github.com/andres-montanez/Magallanes
176+
.. _`bundles that add deployment features`: http://knpbundles.com/search?q=deploy
177+
.. _`Symfony IRC channel`: http://webchat.freenode.net/?channels=symfony
178+
.. _`Memcached`: http://memcached.org/
179+
.. _`Redis`: http://redis.io/

cookbook/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,6 @@ The Cookbook
2727
profiler/index
2828
web_services/index
2929
symfony1
30+
deployment-tools
3031

3132
.. include:: /cookbook/map.rst.inc

cookbook/map.rst.inc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,3 +149,5 @@
149149

150150
* :doc:`/cookbook/workflow/new_project_git`
151151
* :doc:`/cookbook/workflow/new_project_svn`
152+
153+
* :doc:`/cookbook/deployment-tools`

cookbook/templating/PHP.rst

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,23 @@ below renders the ``index.html.php`` template::
5757
return $this->render('AcmeHelloBundle:Hello:index.html.php', array('name' => $name));
5858
}
5959

60+
You can also use the :doc:`/bundles/SensioFrameworkExtraBundle/annotations/view`
61+
shortcut to render the default ``AcmeHelloBundle:Hello:index.html.php`` template::
62+
63+
// src/Acme/HelloBundle/Controller/HelloController.php
64+
65+
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
66+
67+
// ...
68+
69+
/**
70+
* @Template(engine="php")
71+
*/
72+
public function indexAction($name)
73+
{
74+
return array('name' => $name);
75+
}
76+
6077
.. index::
6178
single: Templating; Layout
6279
single: Layout

0 commit comments

Comments
 (0)