diff --git a/_build/redirection_map b/_build/redirection_map index 81af4e938fb..32c3be426e2 100644 --- a/_build/redirection_map +++ b/_build/redirection_map @@ -76,13 +76,20 @@ /book/configuration /configuration /book/propel /propel/propel /book/performance /performance -/cookbook/assetic/apply_to_option /assetic/apply_to_option -/cookbook/assetic/asset_management /assetic/asset_management -/cookbook/assetic/index /assetic -/cookbook/assetic/jpeg_optimize /assetic/jpeg_optimize -/cookbook/assetic/php /assetic/php -/cookbook/assetic/uglifyjs /assetic/uglifyjs -/cookbook/assetic/yuicompressor /assetic/yuicompressor +/cookbook/assetic/apply_to_option /frontend/assetic/apply_to_option +/cookbook/assetic/asset_management /frontend/assetic/asset_management +/cookbook/assetic/index /frontend/assetic +/cookbook/assetic/jpeg_optimize /frontend/assetic/jpeg_optimize +/cookbook/assetic/php /frontend/assetic/php +/cookbook/assetic/uglifyjs /frontend/assetic/uglifyjs +/cookbook/assetic/yuicompressor /frontend/assetic/yuicompressor +/assetic /frontend/assetic +/assetic/apply_to_option /frontend/assetic/apply_to_option +/assetic/asset_management /frontend/assetic/asset_management +/assetic/jpeg_optimize /frontend/assetic/jpeg_optimize +/assetic/php /frontend/assetic/php +/assetic/uglifyjs /frontend/assetic/uglifyjs +/assetic/yuicompressor /frontend/assetic/yuicompressor /cookbook/bundles/best_practices /bundles/best_practices /cookbook/bundles/configuration /bundles/configuration /cookbook/bundles/extension /bundles/extension @@ -150,7 +157,8 @@ /cookbook/event_dispatcher/event_listener /event_dispatcher /cookbook/event_dispatcher/index /event_dispatcher /cookbook/event_dispatcher/method_behavior /event_dispatcher/method_behavior -/cookbook/expressions /expressions/expressions +/cookbook/expressions /security/expressions +/expressions /security/expressions /cookbook/form/create_custom_field_type /form/create_custom_field_type /cookbook/form/create_form_type_extension /form/create_form_type_extension /cookbook/form/data_transformers /form/data_transformers @@ -181,10 +189,10 @@ /cookbook/profiler/matchers /profiler/matchers /cookbook/profiler/profiling_data /profiler/profiling_data /cookbook/profiler/storage /profiler/storage -/cookbook/psr7 /request/psr7 +/cookbook/psr7 /components/psr7 /cookbook/request/index /request -/cookbook/request/load_balancer_reverse_proxy /request/load_balancer_reverse_proxy -/cookbook/request/mime_type /request/mime_type +/cookbook/request/load_balancer_reverse_proxy /deployment/proxies +/cookbook/request/mime_type /reference/configuration/framework#formats /cookbook/routing/conditions /routing/conditions /cookbook/routing/custom_route_loader /routing/custom_route_loader /cookbook/routing/debug /routing/debug @@ -303,6 +311,7 @@ /components/form/type_guesser /form/type_guesser /components/http_foundation/index /components/http_foundation /components/http_foundation/introduction /components/http_foundation +/components/http_foundation/trusting_proxies /deployment/proxies /components/http_kernel/introduction /components/http_kernel /components/http_kernel/index /components/http_kernel /components/property_access/introduction /components/property_access @@ -327,3 +336,4 @@ /form /forms /testing/simulating_authentication /testing/http_authentication /validation/group_service_resolver /form/validation_group_service_resolver +/request/load_balancer_reverse_proxy /deployment/proxies \ No newline at end of file diff --git a/best_practices/web-assets.rst b/best_practices/web-assets.rst index 62398ebed93..22c95fddd62 100644 --- a/best_practices/web-assets.rst +++ b/best_practices/web-assets.rst @@ -49,7 +49,7 @@ tools like GruntJS. Use Assetic to compile, combine and minimize web assets, unless you're comfortable with frontend tools like GruntJS. -:doc:`Assetic ` is an asset manager capable +:doc:`Assetic ` is an asset manager capable of compiling assets developed with a lot of different frontend technologies like LESS, Sass and CoffeeScript. Combining all your assets with Assetic is a matter of wrapping all the assets with a single Twig tag: @@ -87,8 +87,8 @@ Learn More about Assetic ------------------------ Assetic can also minimize CSS and JavaScript assets -:doc:`using UglifyCSS/UglifyJS ` to speed up your -websites. You can even :doc:`compress images ` +:doc:`using UglifyCSS/UglifyJS ` to speed up your +websites. You can even :doc:`compress images ` with Assetic to reduce their size before serving them to the user. Check out the `official Assetic documentation`_ to learn more about all the available features. diff --git a/components/expression_language.rst b/components/expression_language.rst index ad7f3f924f6..348096e5dd9 100644 --- a/components/expression_language.rst +++ b/components/expression_language.rst @@ -119,7 +119,6 @@ Learn More :maxdepth: 1 :glob: - /expressions /components/expression_language/* /service_container/expression_language /reference/constraints/Expression diff --git a/components/http_foundation.rst b/components/http_foundation.rst index 6d2b6797ea0..224632f55d8 100644 --- a/components/http_foundation.rst +++ b/components/http_foundation.rst @@ -611,7 +611,6 @@ Learn More /components/http_foundation/* /controller /controller/* - /request/* /session/* /http_cache/* diff --git a/components/http_foundation/trusting_proxies.rst b/components/http_foundation/trusting_proxies.rst index 9fc5ead0f36..13dda122fc7 100644 --- a/components/http_foundation/trusting_proxies.rst +++ b/components/http_foundation/trusting_proxies.rst @@ -7,7 +7,7 @@ Trusting Proxies .. tip:: If you're using the Symfony Framework, start by reading - :doc:`/request/load_balancer_reverse_proxy`. + :doc:`/deployment/proxies`. If you find yourself behind some sort of proxy - like a load balancer - then certain header information may be sent to you using special ``X-Forwarded-*`` diff --git a/request/psr7.rst b/components/psr7.rst similarity index 95% rename from request/psr7.rst rename to components/psr7.rst index 7eaa9f7343c..32b008413d9 100644 --- a/request/psr7.rst +++ b/components/psr7.rst @@ -13,7 +13,7 @@ Installation You can install the component in 2 different ways: -* :doc:`Install it via Composer ` (`symfony/psr-http-message-bridge on Packagist `_); +* :doc:`Install it via Composer ` (`symfony/psr-http-message-bridge on Packagist`_); * Use the official Git repository (https://github.com/symfony/psr-http-message-bridge). The bridge also needs a PSR-7 implementation to allow converting HttpFoundation @@ -87,3 +87,4 @@ to a :class:`Symfony\\Component\\HttpFoundation\\Response` instance:: .. _`PSR-7`: http://www.php-fig.org/psr/psr-7/ .. _`Zend Diactoros`: https://github.com/zendframework/zend-diactoros +.. _`symfony/psr-http-message-bridge on Packagist`: https://packagist.org/packages/symfony/psr-http-message-bridge diff --git a/request/load_balancer_reverse_proxy.rst b/deployment/proxies.rst similarity index 100% rename from request/load_balancer_reverse_proxy.rst rename to deployment/proxies.rst diff --git a/frontend.rst b/frontend.rst index d6384a72d33..c09d6bb2605 100644 --- a/frontend.rst +++ b/frontend.rst @@ -2,5 +2,11 @@ Front-end ========= See the latest version of the docs for frontend tools. Or, see -:doc:`/assetic`. +:doc:`/frontend/assetic`. +.. toctree:: + :maxdepth: 1 + :glob: + :hidden: + + frontend/* diff --git a/assetic.rst b/frontend/assetic.rst similarity index 100% rename from assetic.rst rename to frontend/assetic.rst diff --git a/assetic/apply_to_option.rst b/frontend/assetic/apply_to_option.rst similarity index 100% rename from assetic/apply_to_option.rst rename to frontend/assetic/apply_to_option.rst diff --git a/assetic/asset_management.rst b/frontend/assetic/asset_management.rst similarity index 99% rename from assetic/asset_management.rst rename to frontend/assetic/asset_management.rst index 88b11a4cfdd..d3fb1e8f6e8 100644 --- a/assetic/asset_management.rst +++ b/frontend/assetic/asset_management.rst @@ -181,7 +181,7 @@ To include an image you can use the ``image`` tag. You can also use Assetic for image optimization. More information in -:doc:`/assetic/jpeg_optimize`. +:doc:`/frontend/assetic/jpeg_optimize`. .. tip:: @@ -441,7 +441,7 @@ into your template: A more detailed guide about configuring and using Assetic filters as well as -details of Assetic's debug mode can be found in :doc:`/assetic/uglifyjs`. +details of Assetic's debug mode can be found in :doc:`/frontend/assetic/uglifyjs`. Controlling the URL Used ------------------------ diff --git a/assetic/jpeg_optimize.rst b/frontend/assetic/jpeg_optimize.rst similarity index 100% rename from assetic/jpeg_optimize.rst rename to frontend/assetic/jpeg_optimize.rst diff --git a/assetic/php.rst b/frontend/assetic/php.rst similarity index 100% rename from assetic/php.rst rename to frontend/assetic/php.rst diff --git a/assetic/uglifyjs.rst b/frontend/assetic/uglifyjs.rst similarity index 100% rename from assetic/uglifyjs.rst rename to frontend/assetic/uglifyjs.rst diff --git a/assetic/yuicompressor.rst b/frontend/assetic/yuicompressor.rst similarity index 98% rename from assetic/yuicompressor.rst rename to frontend/assetic/yuicompressor.rst index 392db7cdeee..25b056ab54c 100644 --- a/assetic/yuicompressor.rst +++ b/frontend/assetic/yuicompressor.rst @@ -8,7 +8,7 @@ How to Minify JavaScripts and Stylesheets with YUI Compressor The YUI Compressor is `no longer maintained by Yahoo`_. That's why you are **strongly advised to avoid using YUI utilities** unless strictly necessary. - Read :doc:`/assetic/uglifyjs` for a modern and up-to-date alternative. + Read :doc:`/frontend/assetic/uglifyjs` for a modern and up-to-date alternative. Yahoo! provides an excellent utility for minifying JavaScripts and stylesheets so they travel over the wire faster, the `YUI Compressor`_. Thanks to Assetic, diff --git a/index.rst b/index.rst index eed3f3f5200..806fddb31ae 100644 --- a/index.rst +++ b/index.rst @@ -37,7 +37,6 @@ Topics .. toctree:: :maxdepth: 1 - assetic bundles console doctrine @@ -45,14 +44,12 @@ Topics deployment email event_dispatcher - expressions forms frontend http_cache logging performance profiler - request routing security session diff --git a/quick_tour/the_view.rst b/quick_tour/the_view.rst index 91de1cfd620..693433805f7 100644 --- a/quick_tour/the_view.rst +++ b/quick_tour/the_view.rst @@ -262,7 +262,7 @@ Symfony provides the ``asset()`` function to deal with them easily: The ``asset()`` function looks for the web assets inside the ``web/`` directory. If you store them in another directory, read -:doc:`this article ` +:doc:`this article ` to learn how to manage web assets. Using the ``asset()`` function, your application is more portable. The reason diff --git a/reference/configuration/framework.rst b/reference/configuration/framework.rst index 18a8595d5cb..e56903a55f9 100644 --- a/reference/configuration/framework.rst +++ b/reference/configuration/framework.rst @@ -50,6 +50,8 @@ Configuration * `ip`_ * :ref:`path ` * `service`_ +* `request`_: + * `formats`_ * `router`_ * `resource`_ * `type`_ @@ -178,7 +180,7 @@ trusted_proxies **type**: ``array`` Configures the IP addresses that should be trusted as proxies. For more -details, see :doc:`/request/load_balancer_reverse_proxy`. +details, see :doc:`/deployment/proxies`. .. versionadded:: 2.3 CIDR notation support was introduced in Symfony 2.3, so you can whitelist @@ -647,6 +649,69 @@ service This setting contains the service id of a custom matcher. +request +~~~~~~~ + +formats +....... + +**type**: ``array`` **default**: ``[]`` + +This setting is used to associate additional request formats (e.g. ``html``) +to one or more mime types (e.g. ``text/html``), which will allow you to use the +format & mime types to call +:method:`Request::getFormat($mimeType) ` or +:method:`Request::getMimeType($format) `. + +In practice, this is important because Symfony uses it to automatically set the +``Content-Type`` header on the ``Response`` (if you don't explicitly set one). +If you pass an array of mime types, the first will be used for the header. + +To configure a ``jsonp`` format: + +.. configuration-block:: + + .. code-block:: yaml + + # app/config/config.yml + framework: + request: + formats: + jsonp: 'application/javascript' + + .. code-block:: xml + + + + + + + + + + application/javascript + + + + + + .. code-block:: php + + // app/config/config.php + $container->loadFromExtension('framework', array( + 'request' => array( + 'formats' => array( + 'jsonp' => 'application/javascript', + ), + ), + )); + router ~~~~~~ diff --git a/reference/dic_tags.rst b/reference/dic_tags.rst index ca0859fbf9d..580d3f94491 100644 --- a/reference/dic_tags.rst +++ b/reference/dic_tags.rst @@ -193,7 +193,7 @@ Finally, apply the filter: {% endjavascripts %} You can also apply your filter via the ``assetic.filters.my_filter.apply_to`` -config option as it's described here: :doc:`/assetic/apply_to_option`. +config option as it's described here: :doc:`/frontend/assetic/apply_to_option`. In order to do that, you must define your filter service in a separate xml config file and point to this file's path via the ``assetic.filters.my_filter.resource`` configuration key. diff --git a/reference/twig_reference.rst b/reference/twig_reference.rst index f3f9c076527..e2e3da905d8 100644 --- a/reference/twig_reference.rst +++ b/reference/twig_reference.rst @@ -781,7 +781,7 @@ Those bundles can have other Twig extensions: * **Assetic** adds the ``{% stylesheets %}``, ``{% javascripts %}`` and ``{% image %}`` tags. You can read more about them in - :doc:`the Assetic Documentation `. + :doc:`the Assetic Documentation `. .. _`Twig Reference`: http://twig.sensiolabs.org/documentation#reference .. _`Twig Extensions repository`: https://github.com/twigphp/Twig-extensions diff --git a/request.rst b/request.rst deleted file mode 100644 index 4106654c85b..00000000000 --- a/request.rst +++ /dev/null @@ -1,8 +0,0 @@ -Request -======= - -.. toctree:: - :maxdepth: 1 - :glob: - - request/* diff --git a/request/mime_type.rst b/request/mime_type.rst deleted file mode 100644 index ea431d070f8..00000000000 --- a/request/mime_type.rst +++ /dev/null @@ -1,118 +0,0 @@ -.. index:: - single: Request; Add a request format and mime type - -How to Register a new Request Format and Mime Type -================================================== - -Every ``Request`` has a "format" (e.g. ``html``, ``json``), which is used -to determine what type of content to return in the ``Response``. In fact, -the request format, accessible via -:method:`Symfony\\Component\\HttpFoundation\\Request::getRequestFormat`, -is used to set the MIME type of the ``Content-Type`` header on the ``Response`` -object. Internally, Symfony contains a map of the most common formats (e.g. -``html``, ``json``) and their associated MIME types (e.g. ``text/html``, -``application/json``). Of course, additional format-MIME type entries can -easily be added. This document will show how you can add the ``jsonp`` format -and corresponding MIME type. - -Configure your New Format -------------------------- - -The FrameworkBundle registers a subscriber that will add formats to incoming requests. - -All you have to do is to configure the ``jsonp`` format: - -.. configuration-block:: - - .. code-block:: yaml - - # app/config/config.yml - framework: - request: - formats: - jsonp: 'application/javascript' - - .. code-block:: xml - - - - - - - - - - application/javascript - - - - - - .. code-block:: php - - // app/config/config.php - $container->loadFromExtension('framework', array( - 'request' => array( - 'formats' => array( - 'jsonp' => 'application/javascript', - ), - ), - )); - -.. tip:: - - You can also associate multiple mime types to a format, but please note that - the preferred one must be the first as it will be used as the content type: - - .. configuration-block:: - - .. code-block:: yaml - - # app/config/config.yml - framework: - request: - formats: - csv: ['text/csv', 'text/plain'] - - .. code-block:: xml - - - - - - - - - - text/csv - text/plain - - - - - - .. code-block:: php - - // app/config/config.php - $container->loadFromExtension('framework', array( - 'request' => array( - 'formats' => array( - 'jsonp' => array( - 'text/csv', - 'text/plain', - ), - ), - ), - )); diff --git a/security.rst b/security.rst index d69bf3dcb16..19b67508701 100644 --- a/security.rst +++ b/security.rst @@ -988,7 +988,7 @@ You can also use expressions inside your templates: Delete -For more details on expressions and security, see :ref:`expressions-security`. +For more details on expressions and security, see :doc:`/security/expressions`. .. _security-secure-objects: diff --git a/expressions.rst b/security/expressions.rst similarity index 79% rename from expressions.rst rename to security/expressions.rst index b61335bbdc2..e9ea4fdb6b8 100644 --- a/expressions.rst +++ b/security/expressions.rst @@ -1,29 +1,13 @@ .. index:: single: Expressions in the Framework -How to use Expressions in Security, Routing, Services, and Validation -===================================================================== - -In Symfony 2.4, a powerful :doc:`ExpressionLanguage ` -component was added to Symfony. This allows us to add highly customized -logic inside configuration. - -The Symfony Framework leverages expressions out of the box in the following -ways: - -* :doc:`Configuring services `; -* :doc:`Route matching conditions `; -* :ref:`Checking security ` (explained below) and - :ref:`access controls with allow_if `; -* :doc:`Validation `. - -For more information about how to create and work with expressions, see -:doc:`/components/expression_language/syntax`. +Security: Complex Access Controls with Expressions +================================================== -.. _expressions-security: +.. seealso:: -Security: Complex Access Controls with Expressions --------------------------------------------------- + The best solution for handling complex authorization rules is to use + the :doc:`Voter System `. In addition to a role like ``ROLE_ADMIN``, the ``isGranted()`` method also accepts an :class:`Symfony\\Component\\ExpressionLanguage\\Expression` object:: diff --git a/templating.rst b/templating.rst index 9e6ff2295af..3bdbf6e961b 100644 --- a/templating.rst +++ b/templating.rst @@ -808,7 +808,7 @@ advantage of Symfony's template inheritance. and JavaScript assets in Symfony. Symfony also packages another library, called Assetic, which follows this philosophy but allows you to do much more interesting things with those assets. For more information on - using Assetic see :doc:`/assetic/asset_management`. + using Assetic see :doc:`/frontend/assetic/asset_management`. Start by adding two blocks to your base template that will hold your assets: one called ``stylesheets`` inside the ``head`` tag and another called ``javascripts``