Skip to content

Commit 218780a

Browse files
committed
Merge branch '2.3' into 2.6
Conflicts: cookbook/form/data_transformers.rst cookbook/security/form_login_setup.rst cookbook/security/remember_me.rst
2 parents 5b71915 + 23f5bc8 commit 218780a

File tree

18 files changed

+521
-87
lines changed

18 files changed

+521
-87
lines changed

best_practices/creating-the-project.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,11 @@ Symfony documentation uses the AppBundle name.
110110
There is no need to prefix the AppBundle with your own vendor (e.g.
111111
AcmeAppBundle), because this application bundle is never going to be
112112
shared.
113+
114+
.. note::
115+
116+
Another reason to create a new bundle is when you're overriding something
117+
in a vendor's bundle (e.g. a controller). See :doc:`/cookbook/bundles/inheritance`.
113118

114119
All in all, this is the typical directory structure of a Symfony application
115120
that follows these best practices:

components/dom_crawler.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,12 @@ and :phpclass:`DOMNode` objects:
301301

302302
The ``html`` method is new in Symfony 2.3.
303303

304+
.. caution::
305+
306+
Due to an issue in PHP, the ``html()`` method returns wrongly decoded HTML
307+
entities in PHP versions lower than 5.3.6 (for example, it returns ````
308+
instead of ``•``).
309+
304310
Links
305311
~~~~~
306312

contributing/code/bugs.rst

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ Before submitting a bug:
1414
* Double-check the official :doc:`documentation </index>` to see if you're not misusing the
1515
framework;
1616

17-
* Ask for assistance on the `users mailing-list`_, the `forum`_, or on the
18-
#symfony `IRC channel`_ if you're not sure if your issue is really a bug.
17+
* Ask for assistance on `Stack Overflow`_ or on the #symfony `IRC channel`_
18+
if you're not sure if your issue is really a bug.
1919

2020
If your problem definitely looks like a bug, report it using the official bug
2121
`tracker`_ and follow some basic rules:
@@ -34,8 +34,7 @@ If your problem definitely looks like a bug, report it using the official bug
3434

3535
* *(optional)* Attach a :doc:`patch <patches>`.
3636

37-
.. _users mailing-list: http://groups.google.com/group/symfony2
38-
.. _forum: http://forum.symfony-project.org/
39-
.. _IRC channel: irc://irc.freenode.net/symfony
37+
.. _`Stack Overflow`: http://stackoverflow.com/questions/tagged/symfony2
38+
.. _IRC channel: http://symfony.com/irc
4039
.. _tracker: https://github.com/symfony/symfony/issues
4140
.. _Symfony Standard Edition: https://github.com/symfony/symfony-standard/

contributing/code/patches.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ work:
110110
* ``2.3``, if you are fixing a bug for an existing feature (you may have
111111
to choose a higher branch if the feature you are fixing was introduced
112112
in a later version);
113-
* ``2.7``, if you are adding a new feature which is backward compatible;
113+
* ``2.8``, if you are adding a new feature which is backward compatible;
114114
* ``master``, if you are adding a new and backward incompatible feature.
115115

116116
.. note::

contributing/code/security.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ Reporting a Security Issue
99
--------------------------
1010

1111
If you think that you have found a security issue in Symfony, don't use the
12-
mailing-list or the bug tracker and don't publish it publicly. Instead, all
13-
security issues must be sent to **security [at] symfony.com**. Emails sent to
14-
this address are forwarded to the Symfony core-team private mailing-list.
12+
bug tracker and don't publish it publicly. Instead, all security issues must
13+
be sent to **security [at] symfony.com**. Emails sent to this address are
14+
forwarded to the Symfony core-team private mailing-list.
1515

1616
Resolving Process
1717
-----------------

contributing/code/standards.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ Structure
100100

101101
* Place unary operators (``!``, ``--``, ...) adjacent to the affected variable;
102102

103+
* Always use `identical comparison`_ unless you need type juggling;
104+
103105
* Add a comma after each array item in a multi-line array, even after the
104106
last one;
105107

@@ -186,3 +188,4 @@ License
186188
.. _`PSR-1`: http://www.php-fig.org/psr/psr-1/
187189
.. _`PSR-2`: http://www.php-fig.org/psr/psr-2/
188190
.. _`PSR-4`: http://www.php-fig.org/psr/psr-4/
191+
.. _`identical comparison`: https://php.net/manual/en/language.operators.comparison.php

cookbook/assetic/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Assetic
55
:maxdepth: 2
66

77
asset_management
8+
php
89
uglifyjs
910
yuicompressor
1011
jpeg_optimize

cookbook/assetic/php.rst

Lines changed: 203 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
1+
.. index::
2+
single: Front-end; Assetic, Bootstrap
3+
4+
Combining, Compiling and Minimizing Web Assets with PHP Libraries
5+
=================================================================
6+
7+
The official Symfony Best Practices recommend to use Assetic to
8+
:doc:`manage web assets </best_practices/web-assets>`, unless you are
9+
comfortable with JavaScript-based front-end tools.
10+
11+
Even if those JavaScript-based solutions are the most suitable ones from a
12+
technical point of view, using pure PHP alternative libraries can be useful in
13+
some scenarios:
14+
15+
* If you can't install or use ``npm`` and the other JavaScript solutions;
16+
* If you prefer to limit the amount of different technologies used in your
17+
applications;
18+
* If you want to simplify application deployment.
19+
20+
In this article, you'll learn how to combine and minimize CSS and JavaScript files
21+
and how to compile Sass files using PHP-only libraries with Assetic.
22+
23+
Installing the Third-Party Compression Libraries
24+
------------------------------------------------
25+
26+
Assetic includes a lot of ready-to-use filters, but it doesn't include their
27+
associated libraries. Therefore, before enabling the filters used in this article,
28+
you must install two libraries. Open a command console, browse to your project
29+
directory and execute the following commands:
30+
31+
.. code-block:: bash
32+
33+
$ composer require leafo/scssphp
34+
$ composer require patchwork/jsqueeze:"~1.0"
35+
36+
It's very important to maintain the ``~1.0`` version constraint for the ``jsqueeze``
37+
dependency because the most recent stable version is not compatible with Assetic.
38+
39+
Organizing your Web Asset Files
40+
-------------------------------
41+
42+
This example will include a setup using the Bootstrap CSS framework, jQuery, FontAwesome
43+
and some regular CSS and and JavaScript application files (called ``main.css`` and
44+
``main.js``). The recommended directory structure for this set-up looks like this:
45+
46+
.. code-block:: text
47+
48+
web/assets/
49+
├── css
50+
│   ├── main.css
51+
│   └── code-highlight.css
52+
├── js
53+
│   ├── bootstrap.js
54+
│   ├── jquery.js
55+
│   └── main.js
56+
└── scss
57+
├── bootstrap
58+
│   ├── _alerts.scss
59+
│   ├── ...
60+
│   ├── _variables.scss
61+
│   ├── _wells.scss
62+
│   └── mixins
63+
│   ├── _alerts.scss
64+
│   ├── ...
65+
│   └── _vendor-prefixes.scss
66+
├── bootstrap.scss
67+
├── font-awesome
68+
│   ├── _animated.scss
69+
│   ├── ...
70+
│   └── _variables.scss
71+
└── font-awesome.scss
72+
73+
Combining and Minimizing CSS Files and Compiling SCSS Files
74+
-----------------------------------------------------------
75+
76+
First, configure a new ``scssphp`` Assetic filter:
77+
78+
.. configuration-block::
79+
80+
.. code-block:: yaml
81+
82+
# app/config/config.yml
83+
assetic:
84+
filters:
85+
scssphp:
86+
formatter: 'Leafo\ScssPhp\Formatter\Compressed'
87+
# ...
88+
89+
.. code-block:: xml
90+
91+
<!-- app/config/config.xml -->
92+
<?xml version="1.0" charset="UTF-8" ?>
93+
<container xmlns="http://symfony.com/schema/dic/services"
94+
xmlns:assetic="http://symfony.com/schema/dic/assetic">
95+
96+
<assetic:config>
97+
<filter name="scssphp" formatter="Leafo\ScssPhp\Formatter\Compressed" />
98+
<!-- ... -->
99+
</assetic:config>
100+
</container>
101+
102+
.. code-block:: php
103+
104+
// app/config/config.php
105+
$container->loadFromExtension('assetic', array(
106+
'filters' => array(
107+
'scssphp' => array(
108+
'formatter' => 'Leafo\ScssPhp\Formatter\Compressed',
109+
),
110+
// ...
111+
),
112+
));
113+
114+
The value of the ``formatter`` option is the fully qualified class name of the
115+
formatter used by the filter to produce the compiled CSS file. Using the
116+
compressed formatter will minimize the the resulting file, regardless of whether
117+
the original files are regular CSS files or SCSS files.
118+
119+
Next, your Twig template to add the ``{% stylesheets %}`` tag defined by Assetic:
120+
121+
.. code-block:: html+jinja
122+
123+
{# app/Resources/views/base.html.twig #}
124+
<!DOCTYPE html>
125+
<html>
126+
<head>
127+
<!-- ... -->
128+
129+
{% stylesheets filter="scssphp" output="css/app.css"
130+
"assets/scss/bootstrap.scss"
131+
"assets/scss/font-awesome.scss"
132+
"assets/css/*.css"
133+
%}
134+
<link rel="stylesheet" href="{{ asset_url }}" />
135+
{% endstylesheets %}
136+
137+
This simple configuration compiles, combines and minifies the SCSS files into a
138+
regular CSS file that's put in ``web/css/app.css``. This is the only CSS file
139+
which will be served to your visitors.
140+
141+
Combining and Minimizing JavaScript Files
142+
-----------------------------------------
143+
144+
First, configure a new ``jsqueeze`` Assetic filter as follows:
145+
146+
.. configuration-block::
147+
148+
.. code-block:: yaml
149+
150+
# app/config/config.yml
151+
assetic:
152+
filters:
153+
jsqueeze: ~
154+
# ...
155+
156+
.. code-block:: xml
157+
158+
<!-- app/config/config.xml -->
159+
<?xml version="1.0" charset="UTF-8" ?>
160+
<container xmlns="http://symfony.com/schema/dic/services"
161+
xmlns:assetic="http://symfony.com/schema/dic/assetic">
162+
163+
<assetic:config>
164+
<filter name="jsqueeze" />
165+
<!-- ... -->
166+
</assetic:config>
167+
</container>
168+
169+
.. code-block:: php
170+
171+
// app/config/config.php
172+
$container->loadFromExtension('assetic', array(
173+
'filters' => array(
174+
'jsqueeze' => null,
175+
// ...
176+
),
177+
));
178+
179+
Next, update the code of your Twig template to add the ``{% javascripts %}`` tag
180+
defined by Assetic:
181+
182+
.. code-block:: html+jinja
183+
184+
<!-- ... -->
185+
186+
{% javascripts filter="?jsqueeze" output="js/app.js"
187+
"assets/js/jquery.js"
188+
"assets/js/bootstrap.js"
189+
"assets/js/main.js"
190+
%}
191+
<script src="{{ asset_url }}"></script>
192+
{% endjavascripts %}
193+
194+
</body>
195+
</html>
196+
197+
This simple configuration combines all the JavaScript files, minimizes the contents
198+
and saves the output in the ``web/js/app.js`` file, which is the one that is
199+
served to your visitors.
200+
201+
The leading ``?`` character in the ``jsqueeze`` filter name tells Assetic to only
202+
apply the filter when *not* in ``debug`` mode. In practice, this means that you'll
203+
see unminified files while developing and minimized files in the ``prod`` environment.

cookbook/bundles/override.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,10 @@ can override the translations from any translation file, as long as it is in
192192
sure that the bundle containing *your* translations is loaded after any
193193
bundle whose translations you're overriding. This is done in ``AppKernel``.
194194

195+
Translation files are also not aware of :doc:`bundle inheritance </cookbook/bundles/inheritance>`.
196+
If you want to override translations from the parent bundle, be sure that the
197+
parent bundle is loaded before the child bundle in the ``AppKernel`` class.
198+
195199
The file that always wins is the one that is placed in
196200
``app/Resources/translations``, as those files are always loaded last.
197-
198201
.. _`the Doctrine documentation`: http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/inheritance-mapping.html#overrides

cookbook/controller/error_pages.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ The cause of this problem is that routing is done before security. If a 404 erro
136136
occurs, the security layer isn't loaded and thus, the ``is_granted()`` function
137137
is undefined. The solution is to add the following check before using this function:
138138

139-
.. code-block:: twig
139+
.. code-block:: jinja
140140
141141
{% if app.user and is_granted('...') %}
142142
{# ... #}

0 commit comments

Comments
 (0)