Skip to content

Commit 564640c

Browse files
committed
Merge branch '2.5' into 2.6
* 2.5: [#4050] Backporting some additions to 2.3 Missing attribute 'original' Fixes concat operator typo Incorporates @wouterj 's suggestion for more realistic usage of bang Changes operator spacing language Adds missing space before return statement Fixes spelling and formatting errors Fixes wrong bullet character Adds bullet addressing bang placement Reverses statement about bang spacing and corresponding examples [RFC] Clarification on formatting for bangs (!) remove first person as per feedback capitalize section title as per feedback instructions for setting SYMFONY_ENV on Heroku for smooth deploys Change: ConsoleTerminateListener => ErrorLoggerListener Removed parameters from service Fix typos in code Conflicts: reference/configuration/framework.rst
2 parents f30f753 + ddc0a50 commit 564640c

File tree

4 files changed

+48
-20
lines changed

4 files changed

+48
-20
lines changed

best_practices/i18n.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ English in the application would be:
8383
<!-- app/Resources/translations/messages.en.xliff -->
8484
<?xml version="1.0"?>
8585
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
86-
<file source-language="en" target-language="en" datatype="plaintext">
86+
<file source-language="en" target-language="en" datatype="plaintext" original="file.ext">
8787
<body>
8888
<trans-unit id="1">
8989
<source>title.post_list</source>

contributing/code/standards.rst

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,26 @@ example containing most features described below:
7979

8080
throw new \RuntimeException(sprintf('Unrecognized dummy option "%s"', $dummy));
8181
}
82+
83+
private function reverseBoolean($value = null, $theSwitch = false)
84+
{
85+
if (!$theSwitch) {
86+
return;
87+
}
88+
89+
return !$value;
90+
}
8291
}
8392

8493
Structure
8594
---------
8695

8796
* Add a single space after each comma delimiter;
8897

89-
* Add a single space around operators (``==``, ``&&``, ...);
98+
* Add a single space around binary operators (``==``, ``&&``, ...), with
99+
the exception of the concatenation (``.``) operator;
100+
101+
* Place unary operators (``!``, ``--``, ...) adjacent to the affected variable;
90102

91103
* Add a comma after each array item in a multi-line array, even after the
92104
last one;

cookbook/console/logging.rst

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ First configure a listener for console terminate events in the service container
190190
# app/config/services.yml
191191
services:
192192
kernel.listener.command_dispatch:
193-
class: Acme\DemoBundle\EventListener\ConsoleTerminateListener
193+
class: Acme\DemoBundle\EventListener\ErrorLoggerListener
194194
arguments:
195195
logger: "@logger"
196196
tags:
@@ -204,12 +204,8 @@ First configure a listener for console terminate events in the service container
204204
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
205205
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
206206
207-
<parameters>
208-
<parameter key="console_exception_listener.class">Acme\DemoBundle\EventListener\ConsoleExceptionListener</parameter>
209-
</parameters>
210-
211207
<services>
212-
<service id="kernel.listener.command_dispatch" class="%console_exception_listener.class%">
208+
<service id="kernel.listener.command_dispatch" class="Acme\DemoBundle\EventListener\ErrorLoggerListener">
213209
<argument type="service" id="logger"/>
214210
<tag name="kernel.event_listener" event="console.terminate" />
215211
</service>
@@ -222,32 +218,28 @@ First configure a listener for console terminate events in the service container
222218
use Symfony\Component\DependencyInjection\Definition;
223219
use Symfony\Component\DependencyInjection\Reference;
224220
225-
$container->setParameter(
226-
'console_exception_listener.class',
227-
'Acme\DemoBundle\EventListener\ConsoleExceptionListener'
228-
);
229-
$definitionConsoleExceptionListener = new Definition(
230-
'%console_exception_listener.class%',
221+
$definitionErrorLoggerListener = new Definition(
222+
'Acme\DemoBundle\EventListener\ErrorLoggerListener',
231223
array(new Reference('logger'))
232224
);
233-
$definitionConsoleExceptionListener->addTag(
225+
$definitionErrorLoggerListener->addTag(
234226
'kernel.event_listener',
235227
array('event' => 'console.terminate')
236228
);
237229
$container->setDefinition(
238230
'kernel.listener.command_dispatch',
239-
$definitionConsoleExceptionListener
231+
$definitionErrorLoggerListener
240232
);
241233
242234
Then implement the actual listener::
243235

244-
// src/Acme/DemoBundle/EventListener/ConsoleExceptionListener.php
236+
// src/Acme/DemoBundle/EventListener/ErrorLoggerListener.php
245237
namespace Acme\DemoBundle\EventListener;
246238

247239
use Symfony\Component\Console\Event\ConsoleTerminateEvent;
248240
use Psr\Log\LoggerInterface;
249241

250-
class ConsoleExceptionListener
242+
class ErrorLoggerListener
251243
{
252244
private $logger;
253245

cookbook/deployment/heroku.rst

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,9 @@ Deploying your Application on Heroku
7171

7272
To deploy your application to Heroku, you must first create a ``Procfile``,
7373
which tells Heroku what command to use to launch the web server with the
74-
correct settings. After you've done that, you can simply ``git push`` and
75-
you're done!
74+
correct document root. After that, you will ensure that your Symfony application
75+
runs the ``prod`` environment, and then you'll be ready to ``git push`` to
76+
Heroku for your first deploy!
7677

7778
Creating a Procfile
7879
~~~~~~~~~~~~~~~~~~~
@@ -110,6 +111,27 @@ create the ``Procfile`` file and to add it to the repository:
110111
[master 35075db] Procfile for Apache and PHP
111112
1 file changed, 1 insertion(+)
112113
114+
Setting the ``prod`` Environment
115+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
116+
117+
During a deploy, Heroku runs ``composer install --no-dev`` to install all of the
118+
dependencies your application requires. However, typical `post-install-commands`_
119+
in ``composer.json``, e.g. to install assets or clear (or pre-warm) caches, run
120+
using Symfony's ``dev`` environment by default.
121+
122+
This is clearly not what you want - the app runs in "production" (even if you
123+
use it just for an experiment, or as a staging environment), and so any build
124+
steps should use the same ``prod`` environment as well.
125+
126+
Thankfully, the solution to this problem is very simple: Symfony will pick up an
127+
environment variable named ``SYMFONY_ENV`` and use that environment if nothing
128+
else is explicitly set. As Heroku exposes all `config vars`_ as environment
129+
variables, you can issue a single command to prepare your app for a deployment:
130+
131+
.. code-block:: bash
132+
133+
$ heroku config:set SYMFONY_ENV=prod
134+
113135
Pushing to Heroku
114136
~~~~~~~~~~~~~~~~~
115137

@@ -193,3 +215,5 @@ You should be seeing your Symfony application in your browser.
193215
.. _`ephemeral file system`: https://devcenter.heroku.com/articles/dynos#ephemeral-filesystem
194216
.. _`Logplex`: https://devcenter.heroku.com/articles/logplex
195217
.. _`verified that the RSA key fingerprint is correct`: https://devcenter.heroku.com/articles/git-repository-ssh-fingerprints
218+
.. _`post-install-commands`: https://getcomposer.org/doc/articles/scripts.md
219+
.. _`config vars`: https://devcenter.heroku.com/articles/config-vars

0 commit comments

Comments
 (0)