Skip to content

Commit c651844

Browse files
committed
Rebased
1 parent 3508fb8 commit c651844

File tree

1 file changed

+4
-288
lines changed

1 file changed

+4
-288
lines changed

reference/configuration/framework.rst

Lines changed: 4 additions & 288 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,6 @@ Configuration
6969
* `gc_probability`_
7070
* `gc_maxlifetime`_
7171
* `save_path`_
72-
* `assets`_
73-
* `base_path`_
74-
* `base_urls`_
75-
* `packages`_
76-
* `version`_
77-
* `version_format`_
7872
* `templating`_
7973
* `hinclude_default_template`_
8074
* :ref:`form <reference-templating-form>`
@@ -814,7 +808,7 @@ start and depends on `gc_divisor`_ and `gc_probability`_.
814808
save_path
815809
.........
816810

817-
**type**: ``string`` **default**: ``%kernel.cache_dir%/sessions``
811+
**type**: ``string`` **default**: ``%kernel.cache.dir%/sessions``
818812

819813
This determines the argument to be passed to the save handler. If you choose
820814
the default file handler, this is the path where the session files are created.
@@ -856,263 +850,11 @@ setting the value to ``null``:
856850
),
857851
));
858852
859-
assets
860-
~~~~~~
861-
862-
.. _reference-assets-base-path:
863-
864-
base_path
865-
.........
866-
867-
**type**: ``string``
868-
869-
This option allows you to define a base path to be used for assets:
870-
871-
.. configuration-block::
872-
873-
.. code-block:: yaml
874-
875-
# app/config/config.yml
876-
framework:
877-
# ...
878-
assets:
879-
base_path: '/images'
880-
881-
.. code-block:: xml
882-
883-
<!-- app/config/config.xml -->
884-
<?xml version="1.0" encoding="UTF-8" ?>
885-
<container xmlns="http://symfony.com/schema/dic/services"
886-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
887-
xmlns:framework="http://symfony.com/schema/dic/symfony"
888-
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
889-
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
890-
891-
<framework:config>
892-
<framework:assets base_path="/images" />
893-
</framework:config>
894-
</container>
895-
896-
.. code-block:: php
897-
898-
// app/config/config.php
899-
$container->loadFromExtension('framework', array(
900-
// ...
901-
'assets' => array(
902-
'base_path' => '/images',
903-
),
904-
));
905-
906-
.. _reference-templating-base-urls:
907-
.. _reference-assets-base-urls:
908-
909-
base_urls
910-
.........
911-
912-
**type**: ``array``
913-
914-
This option allows you to define base URLs to be used for assets.
915-
If multiple base URLs are provided, Symfony will select one from the
916-
collection each time it generates an asset's path:
917-
918-
.. configuration-block::
919-
920-
.. code-block:: yaml
921-
922-
# app/config/config.yml
923-
framework:
924-
# ...
925-
assets:
926-
base_urls:
927-
- 'http://cdn.example.com/'
928-
929-
.. code-block:: xml
930-
931-
<!-- app/config/config.xml -->
932-
<?xml version="1.0" encoding="UTF-8" ?>
933-
<container xmlns="http://symfony.com/schema/dic/services"
934-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
935-
xmlns:framework="http://symfony.com/schema/dic/symfony"
936-
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
937-
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
938-
939-
<framework:config>
940-
<framework:assets base-url="http://cdn.example.com/" />
941-
</framework:config>
942-
</container>
943-
944-
.. code-block:: php
945-
946-
// app/config/config.php
947-
$container->loadFromExtension('framework', array(
948-
// ...
949-
'assets' => array(
950-
'base_urls' => array('http://cdn.example.com/'),
951-
),
952-
));
953-
954-
packages
955-
........
956-
957-
You can group assets into packages, to specify different base URLs for them:
958-
959-
.. configuration-block::
960-
961-
.. code-block:: yaml
962-
963-
# app/config/config.yml
964-
framework:
965-
# ...
966-
assets:
967-
packages:
968-
avatars:
969-
base_urls: 'http://static_cdn.example.com/avatars'
970-
971-
.. code-block:: xml
972-
973-
<!-- app/config/config.xml -->
974-
<?xml version="1.0" encoding="UTF-8" ?>
975-
<container xmlns="http://symfony.com/schema/dic/services"
976-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
977-
xmlns:framework="http://symfony.com/schema/dic/symfony"
978-
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
979-
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
980-
981-
<framework:config>
982-
<framework:assets>
983-
<framework:package
984-
name="avatars"
985-
base-url="http://static_cdn.example.com/avatars" />
986-
</framework:assets>
987-
</framework:config>
988-
</container>
989-
990-
.. code-block:: php
991-
992-
// app/config/config.php
993-
$container->loadFromExtension('framework', array(
994-
// ...
995-
'assets' => array(
996-
'packages' => array(
997-
'avatars' => array(
998-
'base_urls' => 'http://static_cdn.example.com/avatars',
999-
),
1000-
),
1001-
),
1002-
));
1003-
1004-
Now you can use the ``avatars`` package in your templates:
1005-
1006-
.. configuration-block:: php
1007-
1008-
.. code-block:: html+twig
1009-
1010-
<img src="{{ asset('...', 'avatars') }}">
1011-
1012-
.. code-block:: html+php
1013-
1014-
<img src="<?php echo $view['assets']->getUrl('...', 'avatars') ?>">
1015-
1016-
Each package can configure the following options:
1017-
1018-
* :ref:`base_path <reference-assets-base-path>`
1019-
* :ref:`base_urls <reference-assets-base-urls>`
1020-
* :ref:`version <reference-framework-assets-version>`
1021-
* :ref:`version_format <reference-assets-version-format>`
853+
templating
854+
~~~~~~~~~~
1022855

1023856
.. _reference-templating-cache:
1024857

1025-
version
1026-
.......
1027-
1028-
**type**: ``string``
1029-
1030-
This option is used to *bust* the cache on assets by globally adding a query
1031-
parameter to all rendered asset paths (e.g. ``/images/logo.png?v2``). This
1032-
applies only to assets rendered via the Twig ``asset`` function (or PHP
1033-
equivalent) as well as assets rendered with Assetic.
1034-
1035-
For example, suppose you have the following:
1036-
1037-
.. configuration-block::
1038-
1039-
.. code-block:: html+twig
1040-
1041-
<img src="{{ asset('images/logo.png') }}" alt="Symfony!" />
1042-
1043-
.. code-block:: php
1044-
1045-
<img src="<?php echo $view['assets']->getUrl('images/logo.png') ?>" alt="Symfony!" />
1046-
1047-
By default, this will render a path to your image such as ``/images/logo.png``.
1048-
Now, activate the ``version`` option:
1049-
1050-
.. configuration-block::
1051-
1052-
.. code-block:: yaml
1053-
1054-
# app/config/config.yml
1055-
framework:
1056-
# ...
1057-
assets:
1058-
version: 'v2'
1059-
1060-
.. code-block:: xml
1061-
1062-
<!-- app/config/config.xml -->
1063-
<?xml version="1.0" encoding="UTF-8" ?>
1064-
<container xmlns="http://symfony.com/schema/dic/services"
1065-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1066-
xmlns:framework="http://symfony.com/schema/dic/symfony"
1067-
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
1068-
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
1069-
1070-
<framework:config>
1071-
<framework:assets version="v2" />
1072-
</framework:config>
1073-
</container>
1074-
1075-
.. code-block:: php
1076-
1077-
// app/config/config.php
1078-
$container->loadFromExtension('framework', array(
1079-
// ...
1080-
'assets' => array(
1081-
'version' => 'v2',
1082-
),
1083-
));
1084-
1085-
Now, the same asset will be rendered as ``/images/logo.png?v2`` If you use
1086-
this feature, you **must** manually increment the ``version`` value
1087-
before each deployment so that the query parameters change.
1088-
1089-
It's also possible to set the version value on an asset-by-asset basis (instead
1090-
of using the global version - e.g. ``v2`` - set here). See
1091-
:ref:`Versioning by Asset <book-templating-version-by-asset>` for details.
1092-
1093-
You can also control how the query string works via the `version_format`_
1094-
option.
1095-
1096-
.. tip::
1097-
1098-
As with all settings, you can use a parameter as value for the
1099-
``version``. This makes it easier to increment the cache on each
1100-
deployment.
1101-
1102-
.. _reference-templating-version-format:
1103-
.. _reference-assets-version-format:
1104-
1105-
version_format
1106-
..............
1107-
1108-
**type**: ``string`` **default**: ``%%s?%%s``
1109-
1110-
This specifies a :phpfunction:`sprintf` pattern that will be used with the
1111-
`version`_ option to construct an asset's path. By default, the pattern
1112-
adds the asset's version as a query string. For example, if
1113-
``version_format`` is set to ``%%s?version=%%s`` and ``version``
1114-
is set to ``5``, the asset's path would be ``/images/logo.png?version=5``.
1115-
=======
1116858
cache
1117859
.....
1118860

@@ -1129,21 +871,13 @@ is disabled.
1129871
engines
1130872
.......
1131873

1132-
Some CDN's do not support cache-busting via query strings, so injecting
1133-
the version into the actual file path is necessary. Thankfully,
1134-
``version_format`` is not limited to producing versioned query
1135-
strings.
1136-
=======
1137874
**type**: ``string[]`` / ``string`` **required**
1138875

1139876
The Templating Engine to use. This can either be a string (when only one
1140877
engine is configured) or an array of engines.
1141878

1142879
At least one engine is required.
1143880

1144-
templating
1145-
~~~~~~~~~~
1146-
1147881
hinclude_default_template
1148882
.........................
1149883

@@ -1231,8 +965,6 @@ Assume you have custom global form themes in
1231965

1232966
See :ref:`book-forms-theming-global` for more information.
1233967

1234-
.. _reference-templating-cache:
1235-
=======
1236968
loaders
1237969
.......
1238970

@@ -1616,8 +1348,6 @@ cache
16161348
The service that is used to persist class metadata in a cache. The service
16171349
has to implement the :class:`Symfony\\Component\\Validator\\Mapping\\Cache\\CacheInterface`.
16181350

1619-
.. _reference-validation-enable_annotations:
1620-
16211351
enable_annotations
16221352
..................
16231353

@@ -1833,21 +1563,6 @@ Full Default Configuration
18331563
serializer:
18341564
enabled: false
18351565
1836-
# assets configuration
1837-
assets:
1838-
base_path: ~
1839-
base_urls: []
1840-
version: ~
1841-
version_format: '%%s?%%s'
1842-
packages:
1843-
1844-
# Prototype
1845-
name:
1846-
base_path: ~
1847-
base_urls: []
1848-
version: ~
1849-
version_format: '%%s?%%s'
1850-
18511566
# templating configuration
18521567
templating:
18531568
hinclude_default_template: ~
@@ -1896,6 +1611,7 @@ Full Default Configuration
18961611
file_cache_dir: '%kernel.cache_dir%/annotations'
18971612
debug: '%kernel.debug%'
18981613
1614+
.. _`protocol-relative`: http://tools.ietf.org/html/rfc3986#section-4.2
18991615
.. _`HTTP Host header attacks`: http://www.skeletonscribe.net/2013/05/practical-http-host-header-attacks.html
19001616
.. _`Security Advisory Blog post`: https://symfony.com/blog/security-releases-symfony-2-0-24-2-1-12-2-2-5-and-2-3-3-released#cve-2013-4752-request-gethost-poisoning
19011617
.. _`Doctrine Cache`: http://docs.doctrine-project.org/projects/doctrine-common/en/latest/reference/caching.html

0 commit comments

Comments
 (0)